JSON Formatter & Beautifier

Paste API or log JSON on the left. The right side updates as you type: a collapsible tree by default, or Minify, YAML, XML, TypeScript, Go, or Java from the toolbar. Invalid paste? Use JSON repair & validate first, then copy here—pair with JSON compare, JSONPath, or JSON to CSV in the same section.

About this JSON Formatter & Beautifier

The left box holds the JSON you can edit freely. The right side updates in the current mode as you type. If the JSON is invalid, the error appears under the input with a line and column, and the right side keeps the last valid result instead of a half-finished one.

Format shows a collapsible tree on the right, indented with two spaces. Minify shows one colored line. XML, YAML, TypeScript, Go, and Java appear as plain text. Copy takes whatever you currently see on the right: the tree as text, the one-line version, or the converted text.

For invalid paste, use JSON repair & validate first, then return here. Compare two bodies with JSON compare; switch formats via YAML to JSON or XML ↔ JSON; mock data with JSON generator; spreadsheets with JSON to CSV.

JSON formatting essentials

Pretty print vs minify

Pretty print adds indentation and line breaks without changing the data—easier to read and debug. Minify strips whitespace into one line, which is smaller and common in logs or Network panel copies. Both forms represent the same JSON.

What counts as valid standard JSON

  1. Keys and string values must use double quotes, not single quotes.
  2. No // or /* */ comments, and no trailing comma after the last item in an object or array.
  3. Types are limited to objects {}, arrays [], strings, numbers, true, false, and null.
  4. NaN, Infinity, and undefined are not standard JSON. For comments, JSON5-style paste, or messy API text, use JSON repair & validate first.

null, true, false vs quoted strings

In JSON, null, true, and false are literals—do not wrap them in quotes. "null", "true", and "false" are strings with those characters. Numbers are unquoted too; "123" and 123 are different types. Misreading quotes when you compare API docs or exports is a common source of type bugs.

Objects, arrays, and nesting

Objects are key–value maps with unique keys; arrays are ordered lists starting at index 0. API payloads often wrap lists in data, list, or items, or nest objects inside arrays. The tree indents by level; for large JSON, use Find a key or value instead of scanning the whole text.

Typical workflows

One-line API response

Paste a one-line response, click Format, expand status or data, then Copy if you need the readable text elsewhere. The values stay the same; only the spacing changes. To compare two responses, use JSON diff. To flatten nested JSON into one layer, use JSON flatten. To pull values out with a path, use JSONPath tester.

Fixture → YAML for Helm or CI

Validate with Format first, then JSON to YAML. Scan the YAML pane for array indentation before pasting into a values file—keys become nested fields, arrays become repeated list items. Starting from YAML configs, round-trip through YAML to JSON and back here.

Mock data and exports

Generate arrays with JSON generator, format here for docs or Postman. For CSV import tests, continue to JSON to CSV or CSV generator.

Frequently asked questions

Does JSON reformat as I type?
Yes. The right side updates in the current mode as you type, as a tree by default. Incomplete JSON shows the error under the input and keeps the last valid result until the text is valid again.
How do I pretty-print minified JSON?
Paste the one-line string and click Format. The page checks that it is valid JSON, then shows it as a tree indented with two spaces. Numbers like 1.0 may show as 1. That is how JSON works.
What fails validation?
A trailing comma, a comment, single quotes, NaN, Infinity, or a key without quotes. An empty box says “Enter some text first.” Anything else invalid says “Invalid JSON.” You will not get a formatted result from bad input.
JSON5 or trailing commas?
This page accepts standard JSON only. Trailing commas and comments fail here. Use JSON repair & validate, then come back to format or convert.
Format vs Minify?
Both start by checking the JSON. Format shows a tree indented with two spaces. Minify removes spaces and line breaks and shows one colored line.
How do XML and YAML mapping work?
The JSON has to pass the check first. Object keys become XML tag names or YAML fields. Arrays repeat tags or become list items. Copy from the plain-text area when the structure looks right.
How do I convert JSON to TypeScript online?
Paste a JSON object or array and click To TypeScript. An object becomes export interface Root; a nested object such as user becomes interface User; an array of objects becomes export type Root = Item[]. Fields missing from some array elements are optional. Numbers stay number. Pretty-print and minify are unchanged.
How do I convert JSON to a Go struct?
Click To Go. The result is package main with type Root struct and json tags that keep the original key. Integers use int, other numbers use float64, and nested objects become their own struct types.
How do I convert JSON to a Java class?
Click To Java. You get public class Root with private fields, getters, and setters. Nested objects are public static classes. Arrays use List, integers use long, and other numbers use double.
Do TypeScript, Go, and Java conversions escape Unicode?
No. Those three buttons keep characters such as 你好. Escape non-ASCII and Show Chinese apply to Format, Minify, XML, and YAML only.
Is there a free online JSON beautifier with a tree view?
Yes. Paste your JSON and click Format. If it is valid, you get a collapsible tree. Minify, XML and YAML conversion, and copy all stay in your browser. Nothing is uploaded.
How do I unminify or view a one-line API JSON response?
Paste the compact body from curl or Network, click Format, and expand nodes in the tree viewer. Use Minify to go back to one line, or JSON to YAML/XML when the structure looks right.
Format or Minify fails with invalid JSON—what now?
This page does not auto-fix broken paste. Use JSON repair & validate to check or repair trailing commas, comments, or quotes, then return here to format, minify, or convert.
How do I diff two JSON documents after formatting?
Paste each side into JSON compare for added/removed/changed highlights. To align key order first, run JSON key sorter on one or both payloads.
How does this work with YAML or XML converters?
This page starts from JSON toward XML/YAML/TS/Go/Java. If you have YAML or XML, use YAML to JSON or XML ↔ JSON first, then format or convert here.