How to Safely Format JSON Without Leaking API Keys
· 6 min read
To format JSON without leaking API keys, use a formatter that processes the text entirely in your browser, scan the payload for secrets before you do anything else with it, and redact tokens before you copy, save or share the result. Never use a tool's "save", "share" or "recent" feature on real payloads unless you know exactly where that data is stored and who can read it.
That sounds obvious, but formatting is the moment people are least careful. You are debugging, a 4,000-character response is unreadable on one line, and the fastest fix is to paste it into the first result for "json formatter". This guide explains where that paste can end up and gives you a routine that takes seconds.
Where JSON leaks when you format it
The formatting itself is harmless: indenting text does not expose anything. The risk comes from what happens to the text around the formatting step.
| Leak path | What happens | How to avoid it |
|---|---|---|
| Server-side formatting | The tool posts your JSON to its backend to format or validate it. It may be logged, cached or stored. | Use a tool that works offline. If it still formats with the network disabled, it runs locally. |
| Save / share links | The tool stores the payload under a short URL. Some sites list saved items publicly or make them guessable. | Do not save real payloads. If you must share, redact first or use a link that keeps data in the URL fragment. |
| Browser extensions | Extensions with "read and change all your data on all websites" can read anything you paste into a page. | Format sensitive data in a browser profile with no extensions. |
| Clipboard and chat | The formatted output gets pasted into a ticket, Slack or a gist with the token still inside. | Run a secret scan and redact before copying output anywhere. |
| Analytics and error logging | Some tools attach input to error reports or analytics events. | Check the privacy policy and the Network tab while you use the tool. |
Check whether a formatter is really client-side
"We do not store your data" is a claim. You can check the behavior yourself in under a minute with your browser's developer tools:
- Open the formatter, then open DevTools (F12 or Cmd+Option+I) and switch to the Network tab.
- Clear the list, paste a harmless sample such as
{"test": "canary-123"}and click Format. - Look for new requests. Use the filter box to search for
canary-123. If any request body contains it, the text left your machine. - For a stronger test, set the Network throttling dropdown to Offline and format again. A client-side tool keeps working.
Our JSON formatter is built to pass this test: parsing, formatting, validation and secret detection run in your browser, and the security page explains how to verify it.
What counts as a secret in JSON
API keys are the obvious case, but payloads you format during debugging often carry more than that. Watch for:
- Cloud credentials: AWS access key IDs start with
AKIA(long-term) orASIA(temporary) and come with a secret access key. - Provider tokens with recognizable prefixes, for example GitHub tokens (
ghp_,github_pat_), Stripe secret keys (sk_live_) and Slack tokens (xoxb-,xoxp-). - Bearer tokens and JWTs. A JWT is three base64url segments separated by dots and usually starts with
eyJ. Its payload is only encoded, not encrypted, so anyone can read the claims. - Database connection strings with an embedded password, such as
postgres://user:password@host:5432/db. - Private keys (
-----BEGIN PRIVATE KEY-----), webhook signing secrets and session cookies. - Personal data: emails, phone numbers, addresses and payment details in API responses.
A five-step routine for sensitive payloads
- Format locally. Use a browser-only tool or a CLI (
jq . response.jsonorpython -m json.tool response.json). Neither sends data anywhere. - Scan before you share. Run the JSON secret scanner over the payload. It flags keys by known prefixes, suspicious field names like
passwordorclient_secret, and high-entropy strings. - Redact, do not delete. Replace values with a label such as
"[REDACTED:aws_secret]"instead of removing keys, so whoever reads it still sees the structure. - Share the minimum. If a colleague needs one nested object, query just that part with the JSONPath tester instead of sending the whole response.
- Rotate anything that slipped. If a live secret was pasted somewhere you do not control, treat it as exposed and rotate it. Deleting the message does not undo a copy.
Redact JSON from the command line
If the payload is already in a file, jq can redact known fields while keeping the document valid. This walks every object and replaces the value of any key that looks sensitive:
jq 'walk(if type == "object" then
with_entries(
if (.key | test("pass(word)?|secret|token|api[_-]?key|authorization"; "i"))
then .value = "[REDACTED]"
else . end)
else . end)' response.json > response.redacted.jsonwalk is built into jq 1.6 and later. Key-name rules miss secrets stored under neutral names like value or data, so pair this with a pattern-based scan rather than relying on it alone.
Sharing a formatted payload safely
Sometimes you really do need to send a payload to someone. In order of preference:
- Send a redacted copy through a channel your team already trusts (your ticket system or a private repository), not a public paste site.
- If you use a share link, prefer one where the data lives in the URL fragment (the part after
#). Browsers do not send the fragment to the server in HTTP requests, so the host never receives the payload. Anyone with the full link can still read it, so redact first. - Add an expiry or delete the share once the issue is resolved.
This is not hypothetical. In November 2025 researchers reported that saved snippets on two popular formatter sites were publicly listable and contained live credentials. See what happened and what to do.
Make it a habit
The routine above is only useful if it is the default. Bookmark a client-side formatter, keep a redaction one-liner in your shell history, and add secret scanning to your CI so mistakes are caught before they reach a repository. For config files specifically, see how to detect secrets in config files.
FAQ
Is it safe to paste JSON into an online formatter?
It is safe only if the formatter processes the text in your browser and you do not save or share the result. Check with the DevTools Network tab or by going offline; a client-side tool keeps working without a connection.
Do online JSON formatters store my data?
Some do, especially when you click save or share, which creates a stored copy on their server. Tools that format in the browser never receive the text at all. Read the privacy policy and test the Network tab to be sure.
How do I hide API keys before sharing JSON?
Scan the payload with a secret scanner, then replace each flagged value with a label such as "[REDACTED]" so the structure stays readable. Rotate any key that was already shared unredacted.
Can I format JSON offline?
Yes. Use jq . or python -m json.tool in a terminal, your editor's format command, or a browser-based formatter that keeps working with the network disabled.
Is a JWT a secret?
A JWT is a bearer credential: anyone holding a valid token can use it until it expires. Its claims are readable by anyone because they are only base64url encoded, so treat both the token and its contents as sensitive.

