How do I fix 'Invalid JSON' errors?

The 'JSON' (or 'Javascript Object Notation') is the part of the Minecraft command surrounded by square brackets. The square brackets represent an array, and all main objects (curly brackets) are part of that array.

If you haven't set up your array or objects in the right way, Minecraft will be unable to interpret what your command means. Luckily, there are some tools you can use to help you debug this.


The first thing to do in these situations is to format your JSON string to make it easier to read. JSONLint can be used for this. Paste in the part of your command starting from the square bracket, run the validator, and copy out the formatted JSON.

Secondly, you want to validate your JSON string. You can also use JSONLint to validate settings, but I find JSON Formatter & Validator a bit easier to use, as it keeps a history of changes so you can go back to a particular version if you need to.

Here is the breakdown of your JSON string and the errors JSON Formatter & Validator found:

JSON Formatter & Validation output

First thing I can see is that, in your ClickEvent's Value, it's highlighted the 'text' part because the double-quotes you're using here aren't being interpreted the way you want them to. In this case, you want them to be treated as 'text' to be used in your click event later, but at the moment the JSON interpreter thinks they are the 'end' of the JSON statement.

You need to add a backslash to escape your internal double quotes in order for them to be treated as text:

"value": "/tellraw @p{\"text\":\" Come back when you want to teleport \"}"
         ^           | ^     ^  ^                                      ^
          external   |  these ones are 'escaped' because they 
          quote mark |  are 'inside' the external quotes

Let's fix it and run it again:

Validation Output #2

Now there's only one error left. This is happening because the object above the highlighted bracket isn't properly closed with a matching close-bracket:

Missing bracket

The interpreter expects you to close the object before starting a new one:

 [
    "Would you like to teleport?", {
        "text": "Yes",
        "color": "green",
        "bold": "true",
        "clickEvent": {
            "action": "run_command",
            "value": "/tp @p ~ ~4 ~ "
        },
        "hoverEvent": {
            "action": "show_text",
            "value": {
                "text": "Confirm"
            }
        }}, 
         ^ add this

Running again, it seems that fixed the error at that object, but now there's an extra close-bracket at the bottom:

Expecting comma or close square bracket

"Expecting comma or ']'" means that it expects you to add another item (with comma) or end the array (with close-square-bracket). That close-curly-bracket makes no sense here.

Remove that extra curly bracket, and tada!

Valid JSON

Here's your valid JSON array (you can reduce it to a single line and add back the command stuff yourself). I give no guarantees that it will do what you want, but at least it is valid now.

["Would you like to teleport?", {
    "text": "Yes",
    "color": "green",
    "bold": "true",
    "clickEvent": {
        "action": "run_command",
        "value": "/tp @p ~ ~4 ~ "
    },
    "hoverEvent": {
        "action": "show_text",
        "value": {
            "text": "Confirm"
        }
    }
}, {
    "text": "No",
    "color": "red",
    "bold": "true",
    "clickEvent": {
        "action": "run_command",
        "value": "/tellraw @p{\"text\":\"Come back when you want to teleport\"}"
    }
}]

Firstly, the "line" and "columns" are basically referring to the characters in the text. Since all of your code (the command) is all on one line - it makes sense. The column however, is the individual "blocks" each character sits in. Eg.:

  | 0 | 1 | 2 | 3 | 4 |
1 | H | E | L | L | O |

As you can see, the word begins at 'line 1, column 0', and ends at 'line 1, column 4'. So in reference to your error, the 204th character (remember to start at 0!) is the character that is throwing out your command. Oddly enough, however, this error refers to the section of the command after the target (i.e. @p) - including the space.

  | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | ...
1 |   | { | " | t | e | x | t | " | ...

NOTE: It might not be a character that already exists in your command, it could also be a character that is expected, but is not there.