JSON Formatter API

Format, beautify, minify, and validate JSON online. Custom indentation, key sorting, and precise error locations. 100% client-side — your data never leaves your browser.

The JSON Formatter is also available as a free REST API. Send a POST request with a JSON body to https://dot.tools/api/tools/json-formatter — no authentication, no API key, CORS enabled. Successful calls return { "ok": true, "result": { … } }; failures return HTTP 400 or 422 with an error body.

Request body

FieldTypeRequiredDescription
mode"beautify" | "minify" | "validate"requiredBeautify with indentation, minify to a single line, or validate only.
inputstringrequiredThe JSON text to format, minify, or validate.
indent"2" | "4" | "tab"requiredIndentation used when beautifying: 2 spaces, 4 spaces, or tabs.
sortKeysbooleanrequiredSort object keys alphabetically (recursively) before output.

Response

FieldTypeRequiredDescription
outputstringrequiredThe formatted JSON, or the original input in validate mode. Empty when invalid.
validbooleanrequiredWhether the input is valid JSON.
errorunknownrequiredParse error message when invalid.
errorLineunknownrequired1-based line of the parse error when invalid.
errorColumnunknownrequired1-based column of the parse error when invalid.

Example request

curl -X POST https://dot.tools/api/tools/json-formatter \
  -H 'Content-Type: application/json' \
  -d '{
  "mode": "beautify",
  "indent": "2",
  "sortKeys": false,
  "input": "{\"name\":\"dot.tools\",\"version\":\"2.0.0\",\"private\":true,\"tools\":[\"json-formatter\",\"xml-formatter\",\"yaml-json\"],\"meta\":{\"clientSide\":true,\"category\":\"format\"}}"
}'

Sample response

{
  "ok": true,
  "result": {
    "output": "{\n  \"name\": \"dot.tools\",\n  \"version\": \"2.0.0\",\n  \"private\": true,\n  \"tools\": [\n    \"json-formatter\",\n    \"xml-formatter\",\n    \"yaml-json\"\n  ],\n  \"meta\": {\n    \"clientSide\": true,\n    \"category\": \"format\"\n  }\n}",
    "valid": true,
    "error": null,
    "errorLine": null,
    "errorColumn": null
  }
}

Use the free JSON Formatter in your browser, read the JSON Formatter guide, or import the full OpenAPI specification.