Core structure and components
Every raw text payload in commands and JSON files starts with a root object containing a `rawtext` array. The game evaluates each object inside that array in order and concatenates the results into a single string with no automatic spaces between elements. If you want spaces or line breaks (`\n`), you must include them explicitly inside your text literals or translation strings.
Each element in the `rawtext` array uses one primary key to determine what kind of content it renders. You cannot mix multiple primary keys (like `text` and `score`) inside the same array item; instead, place them as separate objects inside the `rawtext` array.
| Component Key | What it does | Notes |
|---|---|---|
| text | Outputs a literal string exactly as written. | Supports `§` formatting codes and `\n` line breaks. |
| translate | Looks up a localization key in the active `.lang` files. | Falls back to rendering the raw key string if no match exists. |
| with | Supplies substitution values (`%s` or `%1$s`) for a `translate` key. | Accepts either an array of strings or nested `rawtext` object. |
| selector | Evaluates a target selector and prints the matched entity names. | Example: `@p`, `@a[tag=winner]`. Joins multiple names with commas. |
| score | Prints a scoreboard value using an object with `name` and `objective`. | `name` accepts player names, `@s`, selectors, or `*` for the reader. |
Translation keys and the with parameter
Hardcoding English strings inside functions or scripts makes a pack impossible to translate cleanly. By using the `translate` key, the server only sends the translation identifier to the client, and each player's client resolves that identifier against their own selected language in `RP/texts/*.lang`.
When a `.lang` entry contains positional tokens like `%s` or numbered tokens like `%1$s` and `%2$s`, you pair `translate` with the `with` key. While `with` accepts a simple array of plain strings (`["10", "Apples"]`), its real power comes from passing a nested `rawtext` object. Doing so lets you inject live entity selectors, scores, or even secondary translation keys directly into the middle of a translated sentence.
pack.arena.victory=§6%1$s§r won the match with §a%2$s§r points!
item.custom_coin.name=Gold CoinSelectors and scoreboard values
The `selector` and `score` components pull live world data at the exact moment the message is sent. In a `selector` component, any valid target selector string works, and if multiple entities match, the game formats them into a comma-separated list automatically. Be aware that selector resolution depends on the execution context: using `@s` requires an execution context set by `/execute` or an NPC dialogue trigger.
For `score`, you pass an object containing `name` and `objective`. Setting `name` to `*` displays the score of whichever player is currently reading the message, which is useful when broadcasting a single `/tellraw @a` command where every player should see their own personal balance.
{
"format_version": "1.17.0",
"minecraft:npc_dialogue": {
"scenes": [
{
"scene_tag": "match_summary",
"npc_name": {
"rawtext": [
{
"translate": "entity.npc.name"
}
]
},
"text": {
"rawtext": [
{
"translate": "pack.arena.victory",
"with": {
"rawtext": [
{
"selector": "@p[tag=arena_winner]"
},
{
"score": {
"name": "@p[tag=arena_winner]",
"objective": "arena_points"
}
}
]
}
}
]
}
}
]
}
}RawMessage in the Script API
When working with `@minecraft/server`, methods such as `Player.sendMessage()`, `Dimension.sendMessage()`, and `ScreenDisplay.setTitle()` accept either a plain string or a `RawMessage` object. Notice that in the Script API, the top-level wrapper is optional when passing a single component, though you still use `rawtext` arrays when chaining multiple fragments or nesting inside `with`.
Keep in mind that `with` inside a Script API `RawMessage` is strict about types: it only accepts an array of strings (`string[]`) or a nested `RawMessage`. You cannot pass raw numbers or booleans into `with` without converting them to strings first (for example, `score.toString()`), or the script will throw a native type error.
import { world } from "@minecraft/server";
export function announceWinner(player) {
const message = {
translate: "pack.arena.victory",
with: {
rawtext: [
{ text: player.name },
{
score: {
name: player.name,
objective: "arena_points"
}
}
]
}
};
world.sendMessage(message);
}Formatting codes and escape sequences
Bedrock raw text does not use JSON keys like `color` or `bold` on text objects. Instead, all visual styling is handled inline using the section sign (`§`) followed by a formatting code, either inside your `.lang` file or inside the `text` string itself. When styling inside a `translate` template, always place `§r` after a `%s` token if you want to prevent a colored player name or item name from bleeding its color into the rest of the sentence.
When writing raw text inside `.mcfunction` files or JSON files, quotes inside a string must be escaped as `\"`, and line breaks are written as `\n`.
Which versions this applies to
Stable in all current Bedrock versions (1.16.0 and above for commands and dialogue; 1.19.50+ for stable @minecraft/server RawMessage support). No experimental toggles required.
When it does not work
| What you see | Why | The fix |
|---|---|---|
| Command fails with: Rawtext error: 'with' must be an array or rawtext object | You passed a single object or a number directly to `with`, or you wrapped a `rawtext` object inside an outer array like `"with": [{ "rawtext": [...] }]`. | Use either an array of plain strings (`"with": ["value1", "value2"]`) or a single JSON object containing the `rawtext` key (`"with": { "rawtext": [...] }`). |
| Chat displays the raw translation key (e.g. 'pack.arena.victory') instead of the sentence | The client could not find the key in the active language file, or there is a space around the `=` sign in your `.lang` entry. | Check `RP/texts/en_US.lang` to ensure the key matches case-for-case with no spaces around `=`, and verify `RP/texts/languages.json` includes `"en_US"`. |
| The score component outputs nothing (blank space) in the middle of the message | The scoreboard objective does not exist yet, or the targeted entity has never had a score initialized on that objective. | Initialize the player's score to 0 using `/scoreboard players add @a <objective> 0` before displaying the raw text message. |
| Syntax error when running /tellraw with Java Edition properties like 'color' or 'clickEvent' | Bedrock raw text only supports `text`, `translate`, `with`, `score`, and `selector`. Properties like `color`, `bold`, `hoverEvent`, and `clickEvent` do not exist in Bedrock. | Remove those keys and use inline `§` formatting codes (such as `§c` for red or `§l` for bold) inside your `text` or `.lang` strings. |
Reference, straight from the game files
Read out of the game itself, so the ids match the version you are building for.
