Serializable label fields
Stay organized with collections
Save and categorize content based on your preferences.
Serializable labels work exactly the same as normal labels
except they also serialize to XML. They should only be used if you are editing
the content of a label programmatically, and wish it to serialize to XML.
Serializable label field

Serializable label field on a collapsed block

Creation
JSON
{
"type": "example_serializable_label",
"message0": "%1",
"args0": [
{
"type": "field_label_serializable",
"name": "FIELDNAME",
"text": "a serializable label"
}
]
}
JavaScript
Blockly.Blocks['example_serializable_label'] = {
init: function() {
this.appendDummyInput()
.appendField(new Blockly.FieldLabelSerializable("a serializable label"), "FIELDNAME");
}
};
The serializable label field takes in an optional value, and an optional css
class string. Both default to an empty string.
Serialization
JSON
The JSON for a serializable label field looks like so:
{
"fields": {
"FIELDNAME": text
}
}
Where FIELDNAME
is a string referencing a serializable label field, and
the value is the value to apply to the field. The value
follows the same rules as the constructor value.
XML
The XML for a serializable label field looks like so:
<field name="FIELDNAME">text</field>
The field
node's name
attribute contains a string referencing a serializable
label field, and the node's inner text is the value to apply to the field.
Validators
Serializable label fields do not support validators, because they are not
editable by a user.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-06-17 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-06-17 UTC."],[[["\u003cp\u003eSerializable labels function identically to regular labels but with the added capability of serializing to XML for programmatic content editing.\u003c/p\u003e\n"],["\u003cp\u003eThese labels are defined using JSON or JavaScript, specifying their type, message, arguments, and field name.\u003c/p\u003e\n"],["\u003cp\u003eSerialization of serializable labels is achieved through JSON or XML, representing the field name and its corresponding text value.\u003c/p\u003e\n"],["\u003cp\u003eUnlike regular labels, serializable labels lack validator support due to their non-editable nature.\u003c/p\u003e\n"]]],[],null,["Serializable labels work exactly the same as [normal labels](/blockly/guides/create-custom-blocks/fields/built-in-fields/label)\nexcept they also serialize to XML. They should only be used if you are editing\nthe content of a label programmatically, and wish it to serialize to XML.\n\nSerializable label field\n\nSerializable label field on a collapsed block\n\nCreation \n\nJSON \n\n {\n \"type\": \"example_serializable_label\",\n \"message0\": \"%1\",\n \"args0\": [\n {\n \"type\": \"field_label_serializable\",\n \"name\": \"FIELDNAME\",\n \"text\": \"a serializable label\"\n }\n ]\n }\n\nJavaScript \n\n Blockly.Blocks['example_serializable_label'] = {\n init: function() {\n this.appendDummyInput()\n .appendField(new Blockly.FieldLabelSerializable(\"a serializable label\"), \"FIELDNAME\");\n }\n };\n\nThe serializable label field takes in an optional value, and an optional css\nclass string. Both default to an empty string.\n\nSerialization \n\nJSON\n\nThe JSON for a serializable label field looks like so: \n\n {\n \"fields\": {\n \"FIELDNAME\": text\n }\n }\n\nWhere `FIELDNAME` is a string referencing a serializable label field, and\nthe value is the value to apply to the field. The value\nfollows the same rules as the constructor value.\n\nXML\n\nThe XML for a serializable label field looks like so: \n\n \u003cfield name=\"FIELDNAME\"\u003etext\u003c/field\u003e\n\nThe `field` node's `name` attribute contains a string referencing a serializable\nlabel field, and the node's inner text is the value to apply to the field.\n\nValidators\n\nSerializable label fields do not support validators, because they are not\neditable by a user."]]