String to JSON Converter
Convert JS object literals, URL query strings, or key-value lines into strict, formatted JSON. Free, browser-based, and built for everyday development tasks.
Quick Answer
The String to JSON Converter turns JS object literals, URL query strings, and key-value lines into strict formatted JSON — auto-detecting the input format. No eval(), everything runs in your browser.
About String to JSON Converter
Half the "invalid JSON" errors in day-to-day work come from text that is almost JSON but not quite: a JavaScript object copied from source code (single quotes, unquoted keys, trailing commas), a query string from a URL, or a block of key: value lines from a config or log. This converter recognizes those formats and produces strict JSON from them — using safe text transforms and parsers rather than eval(), so nothing in the pasted text ever executes.
Why use this tool?
- JS object → JSON — convert objects copied from JavaScript/TypeScript source into valid JSON for configs and APIs
- Query string → JSON — turn URL parameters into a structured object for documentation or test fixtures
- Config extraction — convert key=value or key: value lines (env files, INI-ish configs, log context) into JSON
- Fixing near-JSON — repair trailing commas, single quotes, and unquoted keys in one click
- API test data — build strict JSON payloads quickly from whatever loose format you have on hand
How it works
- 1Paste the string — a JS object literal, a URL or query string, or key-value lines
- 2Leave the mode on Auto-detect, or choose the format explicitly if detection guesses wrong
- 3Click Convert — the tool applies the matching safe transform and validates the result with JSON.parse
- 4The output panel names the detected format and shows the pretty-printed JSON
Common mistakes to avoid
- Expecting code execution — values that are variables, function calls, or template literals cannot be converted; only static literal syntax can become JSON
- Ambiguous auto-detection — a single line like "a=1" could be a query string or a key-value line; when the guess is wrong, pick the mode explicitly
- Nested quotes in JS strings — a single-quoted string containing an unescaped apostrophe (like 'it's') is invalid JS too; fix the source string first
- Numbers vs strings from query strings — query-string values are always strings ("1", not 1) because URLs carry no type information; cast types downstream where it matters
Pro tip
For one-off conversions inside an editor, pasting a JS object into a Node REPL and calling JSON.stringify(obj, null, 2) also works — but this tool is safer for text from untrusted sources, since it never evaluates the input as code.
Frequently Asked Questions
What is the String to JSON Converter?
How do I use the String to JSON Converter?
Is my data private?
What JS object syntax can it fix?
How are query strings converted?
Related Workflows
Related Tools
JSON Parse
Unescape a JSON string literal back into readable, formatted JSON — with deep parsing for nested stringified payloads. Free, browser-based, and built for everyday development tasks.
JSON Stringify
Escape JSON or plain text into a JSON string literal safe to embed in code. Free, browser-based, and built for everyday development tasks.
JSON Formatter & Beautifier
Format, validate, and minify JSON data with syntax highlighting. Runs entirely in your browser — free, fast, and no signup required.
String to Array Converter
Split any delimited string into a JSON or JavaScript array with trim, dedupe, and formatting options. Free, browser-based, and built for everyday development tasks.
Compare
Tool Trust & Transparency
Ecosystem Trust CenterProcessed in
Your browser
Input never sent to any server
Input stored
No
No logs, no accounts required
Common use cases
- Format, validate, or transform code and data without leaving your browser
- Debug encoding, decoding, or conversion issues quickly
- Generate test data or convert between formats in development workflows
Limitations
- Operates entirely in your browser — large inputs may slow older devices
- Output is a best-effort conversion; always validate critical results independently
Last verified: 2026 · Free, no account required · Validate critical output independently
Report an issue →