Waiting for input

Input

Output

 

The formatted JSON appears here as you type.

Ctrl+Enter run / or Ctrl+K search tools Press Ctrl+D to bookmark this page

How to validate JSON

  1. Paste your JSON into the Input box, or drop a file onto it. Checking starts as you type.
  2. A green Valid JSON badge means the whole document follows the JSON standard (RFC 8259). The summary shows how many properties and values it holds and how deeply it is nested.
  3. If something is wrong, the Output box lists each problem with its line, column and a plain-language explanation. Step through them with the arrows, or click one to jump to that spot in your input.

What makes JSON valid

  • The document is exactly one value: an object, an array, a string, a number, true, false or null.
  • Strings and object keys use double quotes. Inside a string, special characters are escaped, for example \", \\ and \n.
  • Items in objects and arrays are separated by commas, with no comma after the last item.
  • Numbers have no leading zeros, no leading +, and no hex notation. 0.5 is valid; .5 is not.
  • There are no comments.

Code that "looks like JSON" often comes from JavaScript or Python and breaks one of these rules. The validator recognises those cases and says where the code came from, for example when it finds None or undefined.

Reading the problem list

Most problems are independent: a trailing comma on line 4 does not affect a comment on line 20, so the validator lists all of them at once and you can fix them in one pass.

Structural problems are different. When a comma or bracket is missing, everything after it is ambiguous, so checking stops there and says so. Fix that one first, and the list updates as you type.

Fix it repairs common mistakes automatically and shows what it changed. Your input is not touched until you choose to use the fixed version.

Syntax validation, not schema validation

This tool checks that the text is well-formed JSON. It does not check that the data has the fields or types your application expects. That is the job of a JSON Schema, which describes required properties, value types and allowed ranges. A document can be valid JSON and still fail a schema check.

Frequently asked questions

Which JSON standard does the validator use?

RFC 8259, the current JSON standard, which matches ECMA-404. Anything it accepts will be accepted by any standard JSON parser.

Why does it say checking stopped at a line?

After a missing comma or bracket, the rest of the document is ambiguous, so further errors could be false alarms. Fix that problem first; the list updates as you type.

Are duplicate keys an error?

The JSON standard does not forbid them, so the document is still valid. The validator warns about them because most parsers keep only the last value, which often hides a bug.

Does it check my data against a JSON Schema?

No. It checks that the text is well-formed JSON. Checking required fields and value types needs a JSON Schema validator.

Is my JSON uploaded anywhere?

No. Validation runs entirely in your browser and nothing you paste is sent to a server.

Validate JSON in your code

Parsing is the validation step: each example below throws or returns an error, with a position, when the JSON is invalid.

Java

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;

public class FormatJson {
    public static void main(String[] args) throws Exception {
        String text = "{\"name\":\"Ada\",\"langs\":[\"en\",\"fr\"],\"active\":true}";

        ObjectMapper mapper = new ObjectMapper();
        // Throws JsonProcessingException (with line and column) on invalid JSON.
        JsonNode tree = mapper.readTree(text);

        // Jackson's default pretty printer puts a space before the colon
        // and keeps short arrays on one line.
        System.out.println(mapper.writerWithDefaultPrettyPrinter().writeValueAsString(tree));
        System.out.println(mapper.writeValueAsString(tree)); // minified
    }
}

Uses Jackson (com.fasterxml.jackson.core:jackson-databind).

JavaScript

// Format (pretty-print) and minify JSON with the built-in JSON object.
// Note: JSON.parse turns integers above 2^53 into approximations.
const text = '{"name":"Ada","langs":["en","fr"],"active":true}';

const value = JSON.parse(text); // throws SyntaxError on invalid JSON

console.log(JSON.stringify(value, null, 2)); // 2-space indent
console.log(JSON.stringify(value)); // minified

Python

import json

text = '{"name":"Ada","langs":["en","fr"],"active":true}'

# Raises json.JSONDecodeError (with .lineno and .colno) on invalid JSON.
value = json.loads(text)

print(json.dumps(value, indent=2, ensure_ascii=False))  # 2-space indent
print(json.dumps(value, separators=(",", ":"), ensure_ascii=False))  # minified

Go

package main

import (
	"bytes"
	"encoding/json"
	"fmt"
)

func main() {
	text := []byte(`{"name":"Ada","langs":["en","fr"],"active":true}`)

	// Indent and Compact work on the raw bytes, so numbers keep their exact text.
	var pretty bytes.Buffer
	if err := json.Indent(&pretty, text, "", "  "); err != nil {
		fmt.Println("invalid JSON:", err) // *json.SyntaxError has an Offset field
		return
	}
	fmt.Println(pretty.String())

	var compact bytes.Buffer
	if err := json.Compact(&compact, text); err != nil {
		fmt.Println("invalid JSON:", err)
		return
	}
	fmt.Println(compact.String())
}

Last verified . Each example is run automatically and its output checked.

Settings

Deletes everything this site keeps in your browser: saved inputs, favorites, theme, accent color and tool options.