Skip to main content

rawops.dev

Skip to tool content

JSON Formatter & Diff

Format, minify, validate, and compare JSON. Interactive tree view and semantic diff. Everything runs in your browser.

Input JSON
{
  "apiVersion": "apps/v1",
  "kind": "Deployment",
  "metadata": {
    "name": "nginx-deployment",
    "labels": {
      "app": "nginx",
      "env": "production"
    }
  },
  "spec": {
    "replicas": 3,
    "selector": {
      "matchLabels": {
        "app": "nginx"
      }
    },
    "template": {
      "spec": {
        "containers": [
          {
            "name": "nginx",
            "image": "nginx:1.27",
            "ports": [
              {
                "containerPort": 80,
                "protocol": "TCP"
              }
            ],
            "resources": {
              "limits": {
                "cpu": "500m",
                "memory": "128Mi"
              }
            },
            "readinessProbe": {
              "httpGet": {
                "path": "/healthz",
                "port": 80
              },
              "initialDelaySeconds": 5,
              "periodSeconds": 10
            }
          }
        ]
      }
    }
  }
}

What is JSON?

JSON (JavaScript Object Notation) is a lightweight data interchange format used everywhere in modern software. APIs, configuration files, infrastructure-as-code, CI/CD pipelines — JSON is the lingua franca of DevOps.

This tool formats (pretty-prints), minifies, validates, and compares JSON entirely in your browser. Nothing is sent to any server. Paste a Kubernetes manifest, a Terraform state file, or an API response and instantly see it formatted or diff two versions side by side.

JSON Diff — Compare Two JSON Documents

The Diff tab performs a semantic comparison of two JSON documents. Unlike text-based diff tools, it understands JSON structure: re-ordering keys doesn't create false positives, and nested changes are shown with full JSON paths. Perfect for comparing API responses, config file versions, Kubernetes manifests before and after changes, or Terraform plan outputs.

  • Added keys (green) — present in the right document but not the left.
  • Removed keys (red) — present in the left document but not the right.
  • Changed values (yellow) — key exists in both but the value differs.
  • Unchanged (grey) — identical in both documents (hidden by default).

Common DevOps Use Cases

  • API responses — Format raw JSON from curl or compare responses before and after a deployment.
  • Kubernetes manifests — Diff two versions of a Deployment YAML (converted to JSON) to spot config drift.
  • Terraform state — Compare terraform show -json output between environments.
  • CI/CD configs — Validate and compare pipeline configurations across branches.
  • Log entries — Format structured JSON logs or diff two log entries to find what changed.

Common JSON Syntax Errors

  • Trailing commas — JSON does not allow trailing commas after the last element.
  • Single quotes — JSON requires double quotes (").
  • Unquoted keys — All object keys must be double-quoted strings.
  • Comments — JSON does not support comments. Use YAML ↔ JSON Converter for commented config files.

Equivalent jq Commands

Pretty-print:

cat data.json | jq '.'

Minify:

cat data.json | jq -c '.'

Diff two files:

diff <(jq -S . a.json) <(jq -S . b.json)

Validate:

echo '{"key": "value"}' | jq empty && echo "Valid" || echo "Invalid"

Privacy First

This JSON formatter and diff tool runs entirely in your browser using native JSON.parse() and JSON.stringify(). Your data never leaves your machine. No external libraries, no API calls, no cookies.

Related Tools & Resources