Raw JSON text format

Raw JSON text is the format Minecraft uses to send and display rich text to players. It can also be sent by players themselves using commands and data packs. Raw JSON text is written in, a human-readable data format.

Java Edition
Raw JSON text is made up of text components. There is a single root component, which can have child components, which can have their own children and so on. Components can also have formatting and interactivity added to them, which is inherited by their children.

A raw JSON text component can be any JSON data type other than JSON null, including JSON string,  JSON array,  JSON object,  JSON boolean, and  JSON number. The game treats booleans and numbers as strings. Strings and arrays are both shorthand for longer object structures, as described below.


 * A string containing plain text to display directly. This is the same as an object that only has a tag. For example,   and   are equivalent.
 * A boolean is converted to a string ("true" or "false") to display directly. This is the same as an object that only has a tag. For example, ,  , and   are equivalent.
 * A number is converted to a string to display directly. This is the same as an object that only has a tag. For example, ,  , and   are equivalent.
 * A list of raw JSON text components. Same as having all components after the first one appended to the first's array. For example,   is equivalent to.
 * A text component object. All non-content tags are optional.
 * Content
 * To be valid, an object must contain the tags for one content type. The different content types and their tags are described below. Having more than one is allowed, but only one is used.
 * Children
 * : A list of additional raw JSON text components to be displayed after this one.
 * A child text component. Child text components inherit all formatting and interactivity from the parent component, unless they explicitly override them.
 * Formatting
 * : Optional. The color to render the content in. Valid values are,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  , and   (cancels out the effects of colors used by parent objects). Set to   to insert any color in the hexadecimal color format. Example: Using   makes the component red. Must be a full 6-digit value, not 3-digit.
 * : Optional. The resource location of the font for this component in the resource pack within . Defaults to.
 * : Optional. Whether to render the content in bold.
 * : Optional. Whether to render the content in italics. Note that text that is italicized by default, such as custom item names, can be unitalicized by setting this to false.
 * : Optional. Whether to underline the content.
 * : Optional. Whether to strikethrough the content.
 * : Optional. Whether to render the content obfuscated.
 * Interactivity
 * : Optional. When the text is shift-clicked by a player, this string is inserted in their chat input. It does not overwrite any existing text the player was writing. This only works in chat messages.
 * : Optional. Allows for events to occur when the player clicks on text. Only work in chat messages and written books, unless specified otherwise.
 * The action to perform when clicked. Valid values are:
 * "open_url": Opens as a URL in the user's default web browser.
 * "open_file": Opens the file at on the user's computer. This is used in messages automatically generated by the game (e.g., on taking a screenshot) and cannot be used by players for security reasons.
 * "run_command": Works in signs, but only on the root text component, not on any children. Activated by the sign. In chat and written books, this has  entered in chat as though the player typed it themselves and pressed enter. This can be used to run commands, provided the player has the required permissions. Since they are being run from chat, commands must be prefixed with the usual "/" slash. In signs, the command is run by the server at the sign's location, with the player who  the sign as @s. Since they are run by the server, sign commands have the same permission level as a command block instead of using the player's permission level, are not restricted by chat length limits, and do not need to be prefixed with a "/" slash.
 * "suggest_command": Opens chat and fills in . If a chat message was already being composed, it is overwritten. This does not work in books.
 * "change_page": Can only be used in written books. Changes to page if that page exists.
 * "copy_to_clipboard": Copies to the clipboard.
 * : The URL, file path, chat, command or book page used by the specified action.
 * : Optional. Allows for a tooltip to be displayed when the player hovers their mouse over text.
 * : The type of tooltip to show. Valid values are:
 * "show_text": Shows a raw JSON text component.
 * "show_item": Shows the tooltip of an item as if it was being hovering over it in an inventory.
 * "show_entity": Shows an entity's name, type, and UUID. Used by.
 * : The formatting and type of this tag varies depending on the action. Deprecated, use instead.
 * show_text: Another raw JSON text component. Can be any valid text component type: string, array, or object. Note that and  do not function within the tooltip.
 * show_item: A string containing the SNBT for an item stack. See Player.dat format.
 * show_entity: A string containing SNBT. The SNBT does not represent the full entity data, but only stores the name, type, and UUID of the entity.
 * : Optional. Hidden if not present. An NBT string containing some JSON that is parsed as a text component and displayed as the name of the entity. If the NBT string cannot be parsed as a text component, the entire tooltip is replaced with the text "Invalid Entity!"
 * : Optional. Hidden if not present. An NBT string containing some plain text that is displayed as the type of the entity. Can be any text.
 * : Optional. Shown as empty line if not present. An NBT string containing some plain text that is displayed as the UUID of the entity. Can be any text.
 * : The formatting of this tag varies depending on the action.
 * show_text: Another raw JSON text component. Can be any valid text component type: string, array, or object. Note that and  do not function within the tooltip.
 * show_item: The item that should be displayed.
 * : The item's resource location. Present minecraft:air if invalid.
 * : Optional. Size of the item stack.
 * : Optional. A string containing the serialized NBT of the additional information about the item, discussed more in the subsections of the player format page.
 * show_entity: The entity that should be displayed.
 * : Optional. Hidden if not present. A raw JSON text that is displayed as the name of the entity.
 * : A string containing the type of the entity, as a resource location. Present minecraft:pig if invalid.
 * : A string containing the UUID of the entity in the hyphenated hexadecimal format. Should be a valid UUID.

Due to the tag, the above format may be recursively nested to produce complex and functional text strings. However, a raw JSON text doesn't have to be complicated at all: virtually all properties are optional and may be left out.

Content types
Raw JSON text components can display several types of content. These tags should be included directly into the text component object.

Plain Text
Displays plain text.


 * The text component.
 * : A string containing plain text to display directly. Can also be a number or boolean that is displayed directly.

Translated Text
Displays a translated piece of text from the currently selected language. This uses the client's selected language, so if players with their games set to different languages are logged into the same server, each will see the component in their own language.

Translations are defined in language files in resource packs, including the built-in resource pack.

Translations can contain slots for text that is not known ahead of time, such as player names. When displaying the translated text, slots will be filled from a provided list of text components. The slots are defined in the language file, and generally take the form  (displays the next component in the list), or   (displays the third component in the list; replace   with whichever index is desired). For example, the built-in English language file contains the translation.


 * The text component.
 * : A translation identifier, corresponding to the identifiers found in loaded language files. Displayed as the corresponding text in the player's selected language. If no corresponding translation can be found, the identifier itself is used as the translated text.
 * : Optional. A list of raw JSON text components to be inserted into slots in the translation text. Ignored if is not present.
 * A raw JSON text component. If no component is provided for a slot, the slot is displayed as no text.

Scoreboard Value
Displays a score from the scoreboard.


 * The text component.
 * Displays a score holder's current score in an objective. Displays nothing if the given score holder or the given objective do not exist, or if the score holder is not tracked in the objective.
 * The name of the score holder whose score should be displayed. This can be a selector like @p or an explicit name. If the text is a selector, the selector must be guaranteed to never select more than one entity, possibly by adding . If the text is , it shows the reader's own score (for example,   shows every online player their own score in the "obj" objective).
 * : The internal name of the objective to display the player's score in.
 * : Optional. If present, this value is displayed regardless of what the score would have been.

Entity Names
Displays the name of one or more entities found by a selector.

If exactly one entity is found, the entity's name is displayed by itself. If more are found, their names are displayed in the form "Name1, Name2, Name3", with gray commas. If none are found, the component is displayed as no text.

Hovering over a name shows a tooltip with the name, type, and UUID of the target. Clicking a player's name suggests a command to whisper to that player. Shift-clicking a player's name inserts that name into chat. Shift-clicking a non-player entity's name inserts its UUID into chat.


 * The text component.
 * A string containing a selector.
 * : Optional, defaults to . A raw JSON text component. Used as the separator between different names, if the component selects multiple entities.

Keybind
Displays the name of the button that is currently bound to a certain configurable control. This uses the client's own control scheme, so if players with different control schemes are logged into the same server, each will see their own keybind.


 * The text component.
 * : A keybind identifier, to be displayed as the name of the button that is currently bound to that action. For example,  displays "e" if the player is using the default control scheme.

NBT Values
Displays NBT values from entities, block entities, or command storage.

NBT strings display their contents. Other NBT values are displayed as SNBT, with no spacing between symbols. If is set to true, the game will instead attempt to parse and display that text as its own raw JSON text component. That usually only works on strings, since JSON and SNBT are not compatible. If is true and parsing fails, the component is displayed as no text. If more than one NBT value is found, either by selecting multiple entities or by using a multi-value path, they are displayed in the form "Value1, Value2, Value3, Value4".


 * The text component.
 * The NBT path used for looking up NBT values from an entity, block entity, or storage. Requires one of, , or . Having more than one is allowed, but only one is used.
 * : Optional, defaults to false. If true, the game attempts to parse the text of each NBT value as a raw JSON text component. Ignored if is not present.
 * : Optional, defaults to . A raw JSON text component. Used as the separator between different tags, if the component selects multiple tags.
 * : A string specifying the coordinates of the block entity from which the NBT value is obtained. The coordinates can be absolute, relative, or local. Ignored if is not present.
 * : A string specifying the target selector for the entity or entities from which the NBT value is obtained. Ignored if is not present.
 * : A string specifying the resource location of the command storage from which the NBT value is obtained. Ignored if is not present.

Component resolution
Certain text content types (,, and ) do not work in all contexts. These content types need to be resolved, which involves retrieving the appropriate data from the world, rendering it into "simple" text components, and replacing the "advanced" text component with that. This resolution can be done by signs, by written books when they are first opened, by boss bar names, and by commands such as  and. It can also be done by the item modifers set_name and set_lore, but only if their tag is set. Custom item names, custom entity names and scoreboard objective names cannot by themselves resolve these components.

Additionally, resolution fixes a single value in place. Therefore, these content types are not dynamic, and don't update to reflect changes in their environment, while "simple" components usually do.

Bedrock Edition

 * The root tag.
 * A list contains all text object.
 * To be valid, an object must contain one content tag:, , , or . Having more than one is allowed, but only one is used.
 * Content: Plain Text
 * : A string containing plain text to display directly.
 * Content: Translated Text
 * : A translation identifier, to be displayed as the corresponding text in the player's selected language. If no corresponding translation can be found, the identifier itself is used as the translation text. This identifier is the same as the identifiers found in lang files from assets or resource packs.
 * : Optional. A list of raw JSON text component arguments to be inserted into slots in the translation text. Ignored if is not present.
 * Translations can contain slots for text that is not known ahead of time, such as player names. These slots are defined in the translation text itself, not in the JSON text component, and generally take the form  (displays the first argument; replace   with whichever index is desired). If no argument is provided for a slot, the slot is not displayed.
 * Content: Scoreboard Value (requires resolution)
 * : Displays a score holder's current score in an objective. Displays nothing if the given score holder or the given objective do not exist, or if the score holder is not tracked in the objective.
 * The name of the score holder whose score should be displayed. This can be a selector like @p or an explicit name. If the text is, it shows the reader's own score (for example,   shows every online player their own score in the "obj" objective).
 * : The internal name of the objective to display the player's score in.
 * : Optional. If present, this value is used regardless of what the score would have been.
 * Content: Entity Names (requires resolution)
 * : A string containing a selector. Displayed as the name of the player or entity found by the selector. If more than one player or entity is found by the selector, their names are displayed in either the form "Name1 and Name2" or the form "Name1, Name2, Name3, and Name4". Hovering over a name shows a tooltip with the name, type, and UUID of the target. Clicking a player's name suggests a command to whisper to that player. Shift-clicking a player's name inserts that name into chat. Shift-clicking a non-player entity's name inserts its UUID into chat.


 * Basic raw text example:

This sends a message to all players saying "Hello World" in English only. See the Translate action to see how to send localized texts.

Appending
Raw text takes in an array of text objects. Each object in the list is added to the previous object. For example, 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.

Breaking lines
You can go down a line by using "\n". For example,

Translate
The translate object allows creators to provide localized text to users. If translate is specified along with text, translate overrides 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.

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

With
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.

If you want to use a translated text inside the "with" component, instead of an array it needs to be another rawtext component (which consists of an array of JSON texts). The following example outputs "Opped Apple".

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

This outputs "Hello Steve" to all players.

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

Outputs: "Hello Steve and Alex"

You can again use a rawtext component to replace the plain string array, like so

Outputs: "Hello Steve and Apple"

Ordering with %%#
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:

Outputs: "Hello Alex and Steve"

Formatting
String formatting is still possible, but not using the JSON tags used in Java Edition. Instead, Formatting codes are used to change text color and style.