JSON Converter
Paste a JSON object or array and DevKitLab rewrites it as YAML for a config file, XML for a legacy integration, CSV for a spreadsheet, TOML for a settings document, JavaScript object syntax for a fixture, or a return-array PHP file. Each target gets its own knobs — delimiter, quote character, root element name, attribute mode, indent size, key sorting — so the output drops into the next tool without a second cleanup pass. Conversion, syntax highlighting, and copy all happen inside your browser tab.
- Six target formats: YAML, XML, CSV, TOML, JavaScript object literal, and PHP return [...] array
- Format-specific controls: CSV delimiter / quote / header / flatten / array expansion, XML root and item names, declaration, attribute mode, YAML indent and key sorting, TOML key sorting
- Live JSON validation with inline error and a friendly hint when an input is not strict JSON
- Syntax-highlighted preview powered by Shiki, plus one-click Copy result and full-tab fullscreen for big payloads
- Local-only conversion: no upload, no telemetry — safe for API responses, internal configs, fixtures, and seed data
Overview
JSON is great for transport, but the place the data is going next usually wants something different — a config file, a spreadsheet, a fixture, a legacy integration. Six format targets cover the conversions developers actually run.
- 01
JSON → YAML
Generate config-ready YAML for tools like Helm charts, GitHub Actions, Docker Compose, OpenAPI specs, and CI pipelines. Tune indent size, sort keys for stable diffs, and quote strings when the consumer is strict about types.
- 02
JSON → XML
Produce XML for partner integrations, RSS feeds, SOAP services, and document workflows. Set the root and item element names, toggle pretty printing, include or skip the <?xml ?> declaration, and opt-in to attribute mode where @id keys become attributes.
- 03
JSON → CSV
Flatten an array of objects into a CSV that opens cleanly in Excel, Google Sheets, BigQuery, or DuckDB. Flatten nested keys to dot paths, choose comma / semicolon / tab / pipe delimiter, switch between double and single quoting, decide how arrays appear, and set the empty-cell character.
- 04
JSON → TOML
Generate TOML for Rust, Hugo, Cargo, Poetry, and other tools that prefer TOML configs. The root must be an object — the converter explains the constraint when it does not match.
- 05
JSON → JS Object
Emit JavaScript object literal syntax (double-quoted keys, JS-friendly indentation) for fixtures, Storybook stories, code review snippets, and inline mocks where strict JSON is not required.
- 06
JSON → PHP Array
Output a complete <?php\n\nreturn [...]; file ready to drop into Laravel config, WordPress samples, Symfony fixtures, or any PHP project that prefers array syntax over a raw JSON include.
- 07
Live JSON validation
Every keystroke is re-parsed. A green badge confirms valid JSON; a red badge with an inline hint points at brackets, commas, or quoting issues — fix the input before chasing a converter bug that is not there.
- 08
Syntax-highlighted preview
Output is rendered with Shiki using language-aware highlighting for YAML, XML, CSV, TOML, JavaScript, and PHP, so structural mistakes — missing closing tags, mis-indented keys — show up visually.
How to use
Four steps. The conversion is recomputed live as you adjust the format or its options.
- 01
Paste a valid JSON object, array, primitive, or null into the input area on the left.
- 02
Pick a target — YAML, XML, CSV, TOML, JS Object, or PHP Array — from the segmented control at the bottom of the workspace.
- 03
Tune the format-specific options that appear next to the selector: CSV delimiter and flatten, XML root / item names, YAML indent and sorting, TOML key sorting.
- 04
Watch the syntax-highlighted result rebuild as you type. Use Copy result to send the output to a config file, spreadsheet, fixture, or downstream service.
Details
Each target has a sweet spot. Pick the format based on where the data goes next, not on which one looks shortest.
- Use YAML for human-readable config — CI pipelines, Helm values, OpenAPI specs, Docker Compose, Ansible playbooks, documentation snippets.
- Use XML when an integration, partner API, SOAP service, RSS feed, or legacy ERP still expects element-based markup.
- Use CSV for spreadsheet imports, ad-hoc analysis in BigQuery / DuckDB / Pandas, BI tool staging, or any hand-off to non-engineers.
- Use TOML for Rust, Cargo, Poetry, Hugo, and modern config files that want typed keys with an object root.
- Use JS Object for JavaScript fixtures, Storybook stories, code snippets in MDX docs, inline mocks, and PR comment examples.
- Use PHP Array for Laravel config files, WordPress samples, Symfony fixtures, and any PHP project that prefers return [...] arrays.
- When the target is "another developer reading this in a ticket", YAML or formatted JSON usually wins on readability.
Use cases
These are the recurring jobs the converter is built to make faster. Same workflow — paste, choose format, tune options, copy — applied to different downstream destinations.
-
API response → spreadsheet handoff
Turn a paginated JSON response into a CSV with flattened keys and a header row so a PM, analyst, or QA can open it in Excel or Google Sheets without writing a script.
-
JSON config → YAML migration
Move project settings, feature flags, or service configs from JSON into YAML when a downstream tool (CI, Kubernetes, OpenAPI) prefers YAML syntax with comments and anchors.
-
JSON → TOML for Rust / Hugo / Poetry
Generate Cargo.toml, pyproject.toml, or Hugo config blocks from a JSON object source of truth and paste the result straight into the tool that consumes it.
-
Legacy XML integration
Convert JSON payloads to XML when integrating with a SOAP service, billing system, SIS, or partner API that still requires element-based markup with attributes.
-
PHP fixture / Laravel config generation
Produce a <?php return [...]; file from API responses or sample data and drop it into a Laravel config, Symfony fixture, or WordPress sample without manually escaping quotes.
-
Storybook / MDX docs fixtures
Convert a JSON sample into a JavaScript object literal for inline mocks, Storybook args, MDX code blocks, and PR comment examples that do not need strict JSON.
-
BigQuery / DuckDB / Pandas staging
Flatten nested JSON into wide CSV rows ready to load into BigQuery, DuckDB, or a Pandas DataFrame for ad-hoc analysis or staging into a BI tool.
-
OpenAPI / JSON Schema doc examples
Generate YAML or XML examples for API documentation directly from JSON fixtures, keeping examples consistent across formats without rewriting by hand.
-
Format comparison while picking a target
Flip between YAML, XML, CSV, TOML, JS Object, and PHP Array on the same input to see which format expresses the data most cleanly before committing to one.
-
Webhook payload → readable post-mortem
Convert a captured Stripe / GitHub / Slack webhook payload to YAML so it reads cleanly in an incident document without screen-wide line wrapping.
See also
If the source is a minified API response or a log snippet, run it through JSON Formatter first so syntax errors and uneven nesting are visible before conversion. When the target is a table workflow and you want to clean the result further, hand the CSV off to CSV Tools for delimiter checks, table preview, column rename, sorting, filtering, and CSV / TSV / JSON / Markdown export.To see exactly what changed between a JSON document before and after conversion — or between two environments — open JSON Diff for a git-style side-by-side diff and a structural change list keyed by JSON Path.For the reverse direction — when the source is YAML, such as a Kubernetes manifest, GitHub Actions workflow, or OpenAPI spec — open YAML Converter to convert YAML into JSON, TOML, XML, JavaScript objects, or PHP arrays. Multi-document files merge into an array, anchors expand by default, and traps like the Norway problem or version-number truncation surface as hints.If you only need to convert one subtree, or want to filter a target array with jq first, use the JSONPath & jq Evaluator to extract the part you need before choosing the output format here.
Best practices
These habits keep conversions predictable as the JSON grows and the target format gets stricter.
- Validate and format the JSON first. If the source is a minified API response, a one-liner log line, or a string from a JS console, run it through the JSON Formatter once before converting.
- For CSV, an array of objects with the same keys gives the cleanest table. Mixed object shapes produce a wide union of columns — flatten or pre-process to a single shape when possible.
- Turn on Flatten nested objects when nested fields should become dot-separated columns like user.email, address.city, metadata.region.
- Turn on Expand arrays only when fixed array positions carry meaning (e.g. tags.0, tags.1). For variable-length lists, stringify arrays so they stay together in one cell.
- For XML, choose root and item element names that match the API or schema the consumer expects — sanitization will alter element names that start with a digit or contain spaces.
- For TOML, keep the source root as a JSON object. Root arrays and root primitives are not valid TOML documents in this converter (or in TOML in general).
- Sort keys when comparing two YAML or TOML outputs across runs — stable order makes diffs reflect real changes instead of ordering noise.
- Review JS Object and PHP Array output before pasting it into a project, especially when string values contain quotes, backslashes, or HTML tags.
Limitations
JSON can represent structures that do not map cleanly to every target. Knowing the boundaries up front avoids "why did the converter do that" moments.
- CSV is fundamentally tabular. Nested objects and arrays must be flattened, stringified, or expanded into indexed columns — some hierarchy is always lost or encoded as a string.
- XML element names are sanitized when JSON keys contain spaces, punctuation, or characters that cannot start an element. A key like "first name" becomes first_name so the XML is valid.
- XML attribute mode only promotes keys that start with @ (or live under _attr) into element attributes. All other keys stay as child elements.
- TOML conversion accepts only object roots. JSON arrays, primitives, or null at the root will be rejected — TOML files describe key-value documents, not bare values.
- YAML output is functional, but production YAML often needs hand-tuned comments, anchors, or multi-line block styles — treat the result as a strong starting point, not a finished file.
- JS Object output uses double-quoted keys for safety. It is JavaScript syntax, not strict JSON — do not feed it back into a JSON parser.
- PHP Array output emits a complete <?php file with return [...];. Review string values that contain backslashes or single quotes before committing into a real project.
- Very large JSON inputs (multi-MB) can slow browser-side conversion and syntax highlighting. For files that big, convert a representative slice first to verify the options.
FAQ
Practical answers about formats, options, privacy, validation, and the trade-offs between targets.
Which JSON conversion formats are supported?
Six targets: YAML, XML, CSV, TOML, JavaScript object literal, and a <?php return [...]; PHP array file. Each has its own option panel for delimiter, indent, root names, sorting, and so on.
Is my JSON uploaded anywhere?
No. Parsing, conversion, syntax highlighting, and copy all run inside your current browser tab. No payload is sent to a server — safe for production responses, internal configs, and sample data with PII.
What does Flatten nested objects do for CSV?
When enabled, nested keys are joined with dots and become individual columns: { "user": { "city": "Tokyo" } } produces a user.city column. When disabled, nested objects are JSON-stringified into a single cell.
What does Expand arrays do for CSV?
When enabled, array items are unrolled into indexed columns: a tags: ["a", "b"] becomes tags.0 and tags.1 columns. When disabled, the whole array is stringified into one cell so its structure is preserved.
Can I customise XML output?
Yes. Set the root element name (default root), item element name (default item), enable pretty printing for line breaks and indentation, include or skip the <?xml version=...?> declaration, and switch on attribute mode where keys prefixed with @ become element attributes.
Why does TOML conversion require an object root?
A TOML document is a set of key-value tables. Top-level arrays, primitives, and null have no valid TOML representation — the converter rejects them with an explicit error rather than producing invalid TOML.
Is JS Object output valid JSON?
No. JS Object output uses JavaScript object literal syntax — meant for fixtures, Storybook stories, inline mocks, and code snippets. Use the original JSON when a strict JSON document is required.
Is PHP Array output a complete PHP file?
Yes. The output starts with <?php followed by return [...];, so the file can be require-d directly from a Laravel config, Symfony fixture, or WordPress sample after a quick review.
Does YAML sorting change the data?
No, only the order of keys in the YAML output. Use it when comparing two converted versions across runs — stable order keeps diffs meaningful instead of showing key-order shuffles.
What about JSON5, JSONC, or NDJSON inputs?
The input parser is strict (RFC 8259). For JSON5 or JSONC (comments, trailing commas, single quotes), run the source through the JSON Formatter's Try repair first. For NDJSON, convert one line at a time.
Why are my XML element names different from my JSON keys?
XML element names cannot start with a digit and cannot contain spaces or most punctuation. Keys that violate those rules are sanitised — "first name" becomes first_name, "2items" becomes _2items — so the resulting XML stays valid.
Can it handle very large JSON files?
Typical API responses and config files up to a few MB convert smoothly. Tens of megabytes will slow the browser; for very large inputs, convert a representative slice first to validate the options before running the full file.
Related tools
Continue the JSON workflow without leaving the data tools collection — validate the source payload, work with the resulting CSV, or run another conversion pass.