Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Minecraft:Text component format

From SAS Gaming Wiki
Revision as of 21:02, 9 April 2026 by SyncBot (talk | contribs) (Fix template calls: add MC/ prefix)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


The text component format, historically also known as raw JSON text, is used by Minecraft to send and display rich-text to players. It can also be sent by players themselves using commands (such as

  1. REDIRECT Template:Command

Template:Redr and

  1. REDIRECT Template:Command

Template:Redr) and data packs.

Java Edition

Template:Hatnote

Text components are written in SNBT, for example Template:Cd. They are used for rich-text formatting in written books, Minecraft:signs, custom names and the

  1. REDIRECT Template:Command

Template:Redr,

  1. REDIRECT Template:Command

Template:Redr,

  1. REDIRECT Template:Command

Template:Redr,

  1. REDIRECT Template:Command

Template:Redr and

  1. REDIRECT Template:Command

Template:Redr commands.

The format 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 component can be a Template:Nbt/sprite string, Template:Nbt/sprite list or a Template:Nbt/sprite object. Strings and lists are both shorthand for longer object structures, as described below.

  • Template:Nbt/sprite A string containing plain text to display directly. This is the same as an object that only has a Template:Nbt/sprite text tag. For example, "A" and {text: "A"} are equivalent.
  • Template:Nbt/sprite A list of components. Same as having all components after the first one appended to the first's Template:Nbt/sprite extra list. For example, ["A", "B", "C"] is equivalent to {text: "A", extra: ["B", "C"]}. Note that because the later components are actually children of the first one, any formatting applied to the first component is inherited by the later ones. For example, [{text: "A", color: "red"}, "B", "C"] will display all three letters with red text.
  • Template:Nbt/sprite A text component object. All non-content tags are optional.
 #vardefine: verifyedition | 

}}<verify for {{#var:verifyedition}}></verify for {{#var:verifyedition}}>{{

 #vardefine: verifyedition | 

}}. Color codes are the ARGB hex code of the color converted to a decimal number, or can be calculated from the opacity, red, green and blue components using this formula:
Alpha<<24 + Red<<16 + Green<<8 + Blue

      • Template:Nbt/sprite shadow_color: Another format. A list containing 4 floats corresponding to red, green, blue, and opacity values as a fraction (ranged 0 to 1, inclusive) that is automatically converted to the int format.
    • Interactivity
      • Template:Nbt/sprite insertion: 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.
      • Template:Nbt/sprite click_event: Optional. Allows for events to occur when the player clicks on text. See Template:Slink.
      • Template:Nbt/sprite hover_event: Optional. Allows for a tooltip to be displayed when the player hovers their mouse over text. See Template:Slink.

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

Content types

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

Plain Text

Displays plain text.

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, the translate key, the fallback key and generally take the form %s (displays the next component in the list), or %3$s (displays the third component in the list; replace 3 with whichever index is desired).<ref group=note>Selecting the "next" argument ignores slots that specify an index explicitly. So if the translation text "Hello %s, %2$s, and %s." was given the components "John" and "Becky", it would display "Hello John, Becky, and Becky."</ref> For example, the built-in English language file contains the translation "chat.type.advancement.task": "%s has made the advancement %s",.

  • Template:Nbt/sprite The text component.
    • Template:Nbt/sprite type: Optional. Set to "translatable".
    • Template:Nbt/sprite translate: 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.
    • Template:Nbt/sprite fallback: Optional. If no corresponding translation can be found, this is used as the translated text. Ignored if Template:Nbt/sprite translate is not present.
    • Template:Nbt/sprite with: Optional. A list of text components to be inserted into slots in the translation text. Ignored if Template:Nbt/sprite translate is not present.
      • A 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.

  • Template:Nbt/sprite The text component.
    • Template:Nbt/sprite type: Optional. Set to "score".
    • Template:Nbt/sprite score: 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.
      • Template:Nbt/sprite name: 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 limit=1. If the text is "*", it shows the reader's own score (for example, /tellraw @a {score: {name: "*", objective: "obj"}} shows every online player their own score in the "obj" objective).<ref group="note">Showing the reader's own score only works in situations where a message has one singular reader. That is chat messages, /titles, and written books. It does not work for bossbar display names or blocks like signs.</ref>
      • Template:Nbt/sprite objective: The internal name of the objective to display the player's score in.

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 Minecraft: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.

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.

  • Template:Nbt/sprite The text component.
    • Template:Nbt/sprite type: Optional. Set to "keybind".
    • Template:Nbt/sprite keybind: A keybind identifier, to be displayed as the name of the button that is currently bound to that action. For example, {keybind: "key.inventory"} displays "e" if the player is using the default control scheme. As a fallback it displays the translation if it exists.

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 Template:Nbt/sprite interpret is set to true, the game will instead attempt to parse and display that text as its own text component. That only works on compounds and lists which contain tags with the proper key names. If Template:Nbt/sprite interpret is true and parsing fails, the component is displayed as no text, or if it directs to a string, shows the string itself. If more than one NBT value is found, either by selecting multiple entities or by using a multi-value path, they are displayed in order, with the Template:Nbt/sprite separator value between them.

Object

Displays objects as single sprites in component messages. Sprites are rendered as 8x8 pixels squares. This will ignore bold and italic styles!

Atlas Object Type

When specifying Template:Nbt/sprite object as "atlas", it displays a single sprite from a texture atlas as a character.

Player Object Type

When specifying Template:Nbt/sprite object as "player" it displays the 2D face sprite of a player profile.

Component resolution

Text component resolution is the process of converting "advanced" (server-side) text components into "simple" (client-side) text components so that they can be displayed to the user.

Certain text component types, such as

  1. REDIRECT Template:Code

Template:Redr,

  1. REDIRECT Template:Code

Template:Redr,

  1. REDIRECT Template:Code

Template:Redr, and

  1. REDIRECT Template:Code

Template:Redr, can be directly displayed by a player client, as the client does not need any additional information to interpret them. Those are known as "client-side" or "simple" text components.

Other types, such as

  1. REDIRECT Template:Code

Template:Redr,

  1. REDIRECT Template:Code

Template:Redr, and

  1. REDIRECT Template:Code

Template:Redr, require additional work from the server before they can be displayed by the client. Those are known as "server-side" or "advanced" text components. As the client does not have access to the information that these text components are meant to display, they need to be resolved by the server, which involves retrieving appropriate data from the world and replacing the server-side text components with client-side ones which the client knows how to render.

If the client receives unresolved server-side text components,

  1. REDIRECT Template:Code

Template:Redr and

  1. REDIRECT Template:Code

Template:Redr text components display as empty text, but

  1. REDIRECT Template:Code

Template:Redr text components display the selector itself.

Additionally, text component resolution fixes a single value in place based on the appropriate data at the moment of resolution. Therefore, these content types are not dynamic, and don't update to reflect later changes. For example, {score:{name:"@p",objective:"points"}} may resolve to

  1. REDIRECT Template:Code

Template:Redr, and will stay that way even if the player's "

  1. REDIRECT Template:Code

Template:Redr" score increases or decreases.

Text component resolution can be done in many ways:

  • Displaying text in chat or title slots with commands such as
  1. REDIRECT Template:Command

Template:Redr and

  1. REDIRECT Template:Command

Template:Redr.

  • Writing a text component to any line on a Minecraft:sign.
  • Writing a text component to a text display's
  1. REDIRECT Template:Code

Template:Redr tag.

  • Using the set_name and set_lore item modifers, but only if their Template:Nbt/sprite entity field is set and that entity context exists.
  • A text component in a written book will be resolved once first opened by an operator or, once placed into a lectern. However, if the resulting text component is too large then it will fail to resolve.
  • Setting a boss bar name using
  1. REDIRECT Template:Command

Template:Redr while the command is executing as an entity.

  1. REDIRECT Template:Command

Template:Redr while the command is executing as an entity.

  1. REDIRECT Template:Command

Template:Redr while the command is executing as an entity.

  • Setting a score holder or scoreboard objective's number format to a
  1. REDIRECT Template:Code

Template:Redr text component using

  1. REDIRECT Template:Command

Template:Redr or

  1. REDIRECT Template:Command

Template:Redr while the command is executing as an entity.

There are several places where text components are not automatically resolved, such as:

  • Writing directly to data components such as Template:DCL, Template:DCL, Template:DCL, and Template:DCL. The previously mentioned item modifiers can be used to resolve text components when writing to these data components.
  • Writing directly to entities'
  1. REDIRECT Template:Code

Template:Redr tag.

  • All text in dialogs.<ref>Template:Bug</ref>
  • Most JSON files in data packs, such as advancement names, chat types, painting variant authors/titles, etc.

Click events

Click events control what happens when the player clicks on the text. Can be one of the following: <section begin="click_events" />

open_url

Opens the specified URL in the user's default web browser.

<section end="click_events" />

open_file

Opens the specified file on the user's computer. This is used in messages automatically generated by the game (e.g., on taking a screenshot) and cannot be sent by servers for security reasons.

<section begin="click_events" />

run_command

Runs the specified command. This runs as if the player typed the specified command in chat and pressed enter. However, this can only be used to run commands that do not send chat messages directly (like

  1. REDIRECT Template:Command

Template:Redr,

  1. REDIRECT Template:Command

Template:Redr, and

  1. REDIRECT Template:Command

Template:Redr). Since they are being run from chat, the player must have the required permissions.

On Minecraft:signs, the command is run by the server at the sign's location, with the player who {{#vardefine: control | right click on mouse or left trigger on gamepad }}used the sign as the command executor (that is, the entity selected by @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, and are not restricted by chat length limits.

suggest_command

Opens chat and fills in the specified text or command. If a chat message was already being composed, it is overwritten.This does not work in books.<ref>Template:Bug</ref>

change_page

Can only be used in written books. Changes to the specified page if that page exists.

copy_to_clipboard

Copies the specified text to the clipboard.

show_dialog

Opens the specified dialog.

custom

Sends a custom event to the server; has no effect on vanilla servers.

<section end="click_events" />

Hover events

Hover events control what happens when the player hovers over the text. Can be one of the following:

show_text

Shows a 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 Template:Nbt/sprite selector.

Bedrock Edition

Unlike Java Edition, text components in Bedrock Edition are written in Minecraft:JSON.

  • Template:Nbt/sprite The root tag.
    • Template:Nbt/sprite rawtext: A list contains all text object.
      • Template:Nbt/sprite To be valid, an object must contain one content tag: Template:Nbt/sprite text, Template:Nbt/sprite translate, Template:Nbt/sprite score, or Template:Nbt/sprite selector. Having more than one is allowed, but only one is used.<ref group=note>Content tags are checked in the order Template:Nbt/sprite translate, Template:Nbt/sprite text, Template:Nbt/sprite selector, Template:Nbt/sprite score. If multiple are present, whichever one comes first in that list is used.</ref>
        • Content: Plain Text
        • Template:Nbt/sprite text: A string containing plain text to display directly.
        • Content: Translated Text
        • Template:Nbt/sprite translate: 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.
        • Template:Nbt/sprite with: Optional. A list of text component arguments to be inserted into slots in the translation text. Ignored if Template:Nbt/sprite translate 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 text component, and generally take the form %%1 (displays the first argument; replace 1 with whichever index is desired). If no argument is provided for a slot, the slot is not displayed.
        • Content: Scoreboard Value (requires resolution)
        • Template:Nbt/sprite score: 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.
          • Template:Nbt/sprite name: 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, /tellraw @a { "rawtext" : [ { "score" : { "name" : "*" , "objective" : "obj"} } ] } shows every online player their own score in the "obj" objective).<ref group="note">Showing the reader's own score only works in situations where a message has one singular reader. That is chat messages, /titleraws, and written books.{{
 #vardefine: verifyedition | 

}}<verify for {{#var:verifyedition}}></verify for {{#var:verifyedition}}>{{

 #vardefine: verifyedition | 

}} It doesn't work for things like signs that can have more than one "reader".{{

 #vardefine: verifyedition | 

}}<verify for {{#var:verifyedition}}></verify for {{#var:verifyedition}}>{{

 #vardefine: verifyedition | 

}}</ref>

          • Template:Nbt/sprite objective: The internal name of the objective to display the player's score in.
        • Content: Entity Names (requires resolution)
        • Template:Nbt/sprite selector: 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 Minecraft: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
Template:Cmd

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, Template:Cmd 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,

Template:Cmd

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.

Template:Cmd

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

Template:Cmd

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

  1. REDIRECT Template:Code

Template:Redr instead of curly brackets Template:Cd.

Template:Cmd

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 text components). The following example outputs "Opped Apple".

Template:Cmd

%%s

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

Template:Cmd

This outputs "Hello Steve" to all players.

Multiple %s

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

Template:Cmd

Outputs: "Hello Steve and Alex"

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

Template:Cmd

Outputs: "Hello Steve and Apple"

Ordering with %%#

The order to fill in %%s 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:

Template:Cmd

Outputs: "Hello Alex and Steve"

Formatting

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

History

Java Edition

Template:HistoryTable

Bedrock Edition

Template:HistoryTable

See also

Notes

Template:Notelist

References

<references group="">

 </references>

External links

Navigation

Template:Navbox Java Edition technical

de:Textkomponenten ja:Raw JSONテキストフォーマット pt:Formato de componente de texto zh:文本组件