Bedrock Edition raw JSON text format

From Minecraft Wiki
Jump to: navigation, search
Information icon.svg
This feature is exclusive to Bedrock Edition.

Raw JSON text is a way to add modifications to text that is displayed – this can be color, or even displaying localized text based on the locale of the user.

In Bedrock Edition, raw JSON text is supported in chat with /tellraw, in titles with /title, in book texts (except title and author), and on signs.

Raw text format[edit]

The format of raw JSON text in Bedrock Edition is a JSON Object which supports the following (mostly optional) elements:

  • The base chat component Object
    •  text: A string representing raw text to display directly in chat. Note that selectors such as "@a" and "@p" are not translated into player names; "\n" is newline (enter). The string entered for text will not be displayed if translate is specified.
    •  translate: The translation identifier of text to be displayed using the player's selected language. This identifier is the same as the identifiers found in lang files from assets or resource packs.
    •  with: A list of chat component arguments and/or string arguments to be used by translate.
      • The arguments are text corresponding to the arguments used by the translation string in the current language, in order (for example, the first list element corresponds to "%1$s" in a translation string).
Basic raw text example
/tellraw @a { "rawtext" : [ { "text" : "Hello world" } ] }

This will send a message to all players saying "Hello World". However this will only be in English, see the Translate action to see how to send localized texts.

Appending[edit]

Raw text takes in an array of text objects. Each object in the list will be added to the previous object. For example, /tellraw @a { "rawtext" : [ { "text":"Hello" }, { "text" : " World" } ] } outputs the same "Hello World" as the first example. Appending text can be useful to combine 2 different localized texts, or apply different colors to each word etc.

Translate[edit]

The translate object allows creators to provide localized text to users. If translate is specified along with text, translate will override the text object. The string to provide to translate is the name of the string in the language files. For example in Vanilla Minecraft "commands.op.success" is the string that displays when /op is used on a player successfully.

/tellraw @a { "rawtext": [ { "translate" : "commands.op.success" } ] }

This will output "Opped %s" to all players. Note that because of text being ignored with translate specified, the following example will output the same text:

/tellraw @a { "rawtext" : [ { "text":"Hello World", "translate":"commands.op.success" } ] }

With[edit]

In the translate example above, it outputs "Opped %s". To have a name or other text show up instead of %s "with" needs to be specified as well. Note that "with" only works with "translate" and also requires an array [] instead of curly brackets {} .

/tellraw @a { "rawtext": [ { "translate" : "commands.op.success", "with": [ "Steve" ] } ] }

%%s[edit]

"translate" and "%s" can be used without needing a corresponding string in the localization files. For example:

/tellraw @a { "rawtext": [ { "translate" : "Hello %%s", "with": [ "Steve" ] } ] }

This outputs "Hello Steve" to all players.

Multiple %s[edit]

%%s can be used multiple.times. They will be filled in, in the order specified

/tellraw @a { "rawtext": [ { "translate" : "Hello %%s and %%s", "with": [ "Steve", "Alex" ] } ] }

Outputs: "Hello Steve and Alex"

Ordering with %%#[edit]

The order to fill in %s to be filled in can be changed by instead specifying it with %%#, replacing # with an actual number. For example to swap the position of Steve and Alex in the above example, instead run the following:

/tellraw @a { "rawtext" : [ {"translate" : "Hello %%2 and %%1", "with": [ "Steve", "Alex"] } ] }

Outputs: "Hello Alex and Steve"