CSP Generator
Build a Content-Security-Policy header directive by directive.
Turn a JSON object into a TOML document with proper tables and arrays of tables.
The JSON to TOML converter writes nested objects as [table] headers and arrays of objects as [[table]] blocks, with every scalar key placed above the first header beneath it so the scoping is correct.
TOML is what Rust, Python packaging and a growing number of tools expect for configuration, and hand-translating a JSON config into it is fiddly. This converter does the structural work: nested objects become [table] headers, arrays of objects become [[table]] blocks.
The ordering rule is applied automatically. Every scalar key in a section is written before the first table header beneath it, because TOML would otherwise read it as belonging to that table. Strings are quoted and escaped, multi-line strings use the triple-quote form, arrays of scalars stay inline, and keys that are not bare-safe get quoted. The root must be an object, since a TOML document is a table.
Scalars are written before the first table header in their section, because TOML would otherwise read them as part of that table.
A list of objects becomes a repeated [[header]] block, which is the only TOML form for structured entries.
Arrays of scalars stay on one line rather than being expanded into something harder to read.
A key that is not bare-safe is quoted automatically, so the output always parses.
A value containing line breaks uses the triple-quote form instead of a wall of escape sequences.
The root must be an object — a TOML document is a table.
Nested objects become [headers] and arrays of objects become [[headers]].
Plain keys are written above the first table header, as TOML requires.
Ready to paste into Cargo.toml, pyproject.toml or your own config.
A TOML document is a table by definition, so there is nowhere for a bare array or string to live at the top level. Wrap the value in an object with a named key.
As an array of tables: the [[header]] is repeated once per element. That is the only TOML form for a list of structured entries.
TOML has no null. Nulls become empty strings, which is the closest equivalent — so remove the key entirely if "absent" is what you mean.
Yes. Each level adds a dotted segment to the table header, so a.b.c becomes [a.b.c].
What people who use the JSON to TOML think of it. Reviews come from visitors and are posted as written.
No ratings yet
Yours would be the first.
0 reviews
Newest first
No reviews yet
Be the first to rate the JSON to TOML. It takes half a minute and no account.
Write the first reviewBuild a Content-Security-Policy header directive by directive.
Re-indent JavaScript, with strings and regular expressions left alone.
Render Markdown to clean HTML, with tables, task lists and fenced code.
Generate Luhn-valid test card numbers that no processor will ever charge.
Check any number against the Luhn checksum and see the working.
Press any key and see event.key, event.code and the modifier state.
Run XPath expressions against your own XML and see every node that matches.
Convert a start and end address into the smallest set of CIDR blocks.