DevToolsForYou
Private by defaultRuns in your browser

JSON formatter / minifier / validator

Pretty-print API payloads, minify JSON for transport, and validate malformed objects or arrays in one focused tool.

Quick samplesClick to load
JSON Formatter

About this tool

JSON (JavaScript Object Notation) is the most widely used data interchange format on the web. Nearly every REST API, configuration file, and web application either produces or consumes JSON. Despite its simplicity, working with raw or minified JSON — especially large nested payloads — is difficult without proper tooling. This tool gives you three operations in one workspace: Format, Minify, and Validate. Formatting expands compressed JSON into an indented, readable structure with consistent spacing. Minification strips all unnecessary whitespace, reducing payload size for transport or storage. Validation checks whether a string is syntactically valid JSON and reports exactly where the error occurs when it is not. A common workflow is to paste a raw API response, format it to understand the structure, then minify it when saving it as a test fixture. The validator is especially useful when hand-editing JSON or generating it in code and being unsure about trailing commas, mismatched brackets, or unquoted keys.

No signup requiredRuns in your browserInstant results
How to use
  1. 1

    Paste your raw or minified JSON into the input field.

  2. 2

    Choose Format to beautify with indentation, Minify to compress it, or Validate to check for syntax errors.

  3. 3

    Errors are highlighted inline so you can pinpoint exactly what is wrong.

  4. 4

    Click Copy to copy the formatted output to your clipboard.

Why use this tool?
  • Format API responses into readable JSON before debugging nested structures.

  • Minify payloads before saving fixtures or sharing compact examples.

  • Validate incoming JSON and catch syntax issues quickly in the browser.

ExamplesInput → output

Format minified JSON

Input{"name":"Alice","age":30,"active":true}
Output{ "name": "Alice", "age": 30, "active": true }

Minify formatted JSON

Input{ "name": "Alice", "age": 30 }
Output{"name":"Alice","age":30}
Common errorsAnd how to fix them

Trailing comma after the last property or array item

Cause: JavaScript allows trailing commas in objects and arrays, but the JSON specification does not. Copying code snippets or writing JSON by hand often introduces this mistake.

Fix: Remove the comma after the last property in an object or the last item in an array. Example: {"a":1, "b":2,} → {"a":1, "b":2}

Single quotes instead of double quotes

Cause: JSON requires double quotes around both keys and string values. Using single quotes (a common JavaScript habit) produces invalid JSON.

Fix: Replace all single-quoted keys and values with double quotes. Example: {'name':'Alice'} → {"name":"Alice"}

Unquoted keys

Cause: JavaScript object literals allow unquoted keys, but JSON does not. Keys must always be double-quoted strings.

Fix: Wrap every key in double quotes. Example: {name: "Alice"} → {"name": "Alice"}

Unexpected end of input

Cause: A closing brace }, bracket ], or quote mark is missing. The JSON parser reached the end of the string without completing the structure.

Fix: Check that every opening { has a matching }, every [ has a matching ], and every string is properly closed. The error position in the validator output points to where parsing stopped.

Frequently asked questionsCommon questions answered

These answers explain common json formatter tasks, expected input formats, and edge cases so both visitors and search engines can understand what this tool does.

What is the difference between formatting and minifying JSON?

Formatting expands JSON with indentation and line breaks to make it easier to read, while minifying removes unnecessary whitespace to make the payload smaller.

Does JSON validation check schema rules?

No. This validator checks whether the input is syntactically valid JSON. It does not validate the structure against a JSON Schema or application-specific rules.

Can I use this tool for API responses and request bodies?

Yes. It is useful for cleaning up request and response payloads, debugging nested objects, and quickly spotting malformed JSON in copied API data.

Why is my JSON invalid?

Common causes include trailing commas, unquoted keys, single quotes instead of double quotes, or missing brackets and braces. The tool surfaces parsing errors when those problems appear.

Code examplesUse this tool in your code

JavaScript has JSON.parse() and JSON.stringify() built in. Use the space parameter of JSON.stringify() for pretty-printing.

JavaScript / Node.jsJavaScript
// Parse JSON string → object
const obj = JSON.parse('{"name":"Alice","age":30}');
console.log(obj.name); // Alice

// Serialize object → JSON string
const json = JSON.stringify(obj);
console.log(json); // {"name":"Alice","age":30}

// Pretty-print with 2-space indentation
const pretty = JSON.stringify(obj, null, 2);
console.log(pretty);
// {
//   "name": "Alice",
//   "age": 30
// }

// Replacer function — exclude null values
const filtered = JSON.stringify(
  { a: 1, b: null, c: "hello" },
  (key, value) => (value === null ? undefined : value),
  2
);

// Reviver — parse dates automatically
const withDates = JSON.parse(
  '{"created":"2023-11-14T22:13:20Z"}',
  (key, value) =>
    typeof value === "string" && /^d{4}-d{2}-d{2}T/.test(value)
      ? new Date(value)
      : value
);
console.log(withDates.created instanceof Date); // true
See full JavaScript / Node.js examples →