Home/Tools/JSON Formatter

JSON Formatter & Validator

Format, validate, and minify JSON instantly in your browser. Syntax highlighting, error detection with line numbers, and zero server-side processing.

Indent:

Input

Output

Formatted JSON will appear here

Examples

What is JSON?

JSON (JavaScript Object Notation) is a lightweight, text-based data interchange format that is easy for humans to read and write and easy for machines to parse and generate. Originally derived from JavaScript, JSON has become the de facto standard for data exchange on the web and is supported natively by virtually every modern programming language including Python, Java, Go, Ruby, PHP, C#, and many more.

JSON is the standard format for REST API request and response bodies, configuration files, and data storage in NoSQL databases like MongoDB and CouchDB. Its simplicity and universality have made it the preferred alternative to XML for most web applications. A valid JSON document must have either an object or an array as its root element, with data expressed as key-value pairs using a minimal set of data types.

JSON Data Types

TypeDescriptionExample
StringUnicode text enclosed in double quotes"hello world"
NumberInteger or floating-point, no leading zeros42, 3.14, -1, 2.5e10
BooleanLogical true or falsetrue, false
nullRepresents an empty or absent valuenull
ObjectUnordered set of key-value pairs in curly braces{"key": "value"}
ArrayOrdered list of values in square brackets[1, 2, 3]

Common JSON Errors

  • Trailing commas— JSON does not allow a comma after the last element in an object or array, unlike JavaScript.
  • Single quotes— JSON requires double quotes for strings and keys. Single quotes ('value') are not valid.
  • Unquoted keys— All object keys must be wrapped in double quotes. {name: "val"} is invalid.
  • Comments— JSON does not support comments of any kind (// or /* */). Use JSONC or JSON5 if you need comments.
  • Undefined values undefined is not a valid JSON value. Use null instead.

JSON vs XML

FeatureJSONXML
ReadabilityCompact, easy to scanVerbose with opening/closing tags
Data typesNative strings, numbers, booleans, null, arrays, objectsEverything is a string by default
File sizeSmaller, less overheadLarger due to repeated tag names
Schema validationJSON Schema (optional)XSD, DTD (mature ecosystem)