/json JSON Formatter & Validator
Pipe messy JSON in, get it validated, indented and colorized back — or a clear parse error pointing at the problem. Like jq . without needing jq installed.
curl --data-binary @data.json curlhub.sh/json
Usage
With curl
curl --data-binary @data.json curlhub.sh/json
printf '{"b":2,"a":1}' | curl --data-binary @- curlhub.sh/json
some-command | curl --data-binary @- curlhub.sh/json
With the CLI
cat data.json | curlhub json
kubectl get pod -o json | curlhub json
Structured output for scripts
curl -s --data-binary @data.json curlhub.sh/json -H 'Accept: application/json'
Output
echo … | curl --data-binary @- curlhub.sh/json
{
"name": "curlhub",
"port": 443,
"secure": true,
"tags": ["cli", "http"]
}
Parameters
| Input | What it does |
|---|---|
--data-binary @- | Read the JSON from stdin — pipe a file or an API response. |
--data-binary @file | Format a file directly. |
Accept: application/json | Return the reserialized JSON (compact/validated) for scripts. |
Recipes
Lint an API response in a pipe
curl -s api.example.com/v1/thing | curl --data-binary @- curlhub.sh/json
A non-zero exit and an error line means the upstream returned invalid JSON.
Pretty-print a config on the fly
cat tsconfig.json | curlhub json