TOML to JSON Converter — Convert TOML to JSON Online Free
Convert TOML configuration files to valid JSON using AI. Handles sections, arrays of tables, inline tables, multi-line strings, and all TOML value types. Free, no sign-up.
TOML to JSON Converter — Convert TOML to JSON Online Free
About TOML to JSON Converter — Convert TOML to JSON Online Free
TOML to JSON converts TOML configuration files into valid JSON, mapping TOML tables to JSON objects, arrays of tables to JSON arrays, and TOML native date/time types to ISO 8601 strings. Developers use it when consuming TOML-based configs (Cargo.toml, pyproject.toml, Hugo config) in JSON-native tools, APIs, or data pipelines.
TOML to JSON Type Mapping
| TOML Type | TOML Example | JSON Output | Notes |
|---|---|---|---|
| String | name = "Alice" | "name": "Alice" | Basic strings map directly |
| Integer | port = 8080 | "port": 8080 | JSON number |
| Float | threshold = 0.75 | "threshold": 0.75 | JSON number |
| Boolean | enabled = true | "enabled": true | JSON boolean |
| Table [section] | [database] | {"database": {"host": "..."}} | Section becomes nested object |
| Array of tables [[t]] | [[items]] id = 1 | {"items": [{"id": 1}]} | Repeated sections become array |
| Inline array | tags = ["a","b"] | "tags": ["a","b"] | Direct JSON array |
| Offset Date-Time | dt = 2024-01-15T10:00:00Z | "dt": "2024-01-15T10:00:00Z" | ISO 8601 string |
TOML vs JSON vs YAML Config Format Comparison
| Feature | TOML | JSON | YAML |
|---|---|---|---|
| Comments | # supported | Not supported | # supported |
| Null values | Not native | null keyword | null / ~ |
| Native date/time types | Yes (RFC 3339) | String only | String only |
| Array of tables | [[name]] syntax | Array of objects | List of mappings |
| Indent sensitive | No | No | Yes |
| Primary use case | Rust/Python configs | APIs, data exchange | Kubernetes, CI/CD |
Frequently Asked Questions
How do I convert a TOML file to JSON in Python?
In Python 3.11+, use the built-in tomllib: import tomllib, json; data = tomllib.loads(toml_string); print(json.dumps(data, indent=2, default=str)). The default=str handles TOML date/time objects. For older Python, install tomli (pip install tomli) which has the same API.
How are TOML dates converted to JSON?
TOML has native date, time, datetime, and offset-datetime types. JSON has no native date type — all TOML dates become ISO 8601 strings in JSON output (e.g., 2024-01-15T10:00:00Z). Your downstream application should parse these strings with Date.parse() or datetime.fromisoformat() as needed.
How are TOML arrays of tables ([[name]]) converted to JSON?
Each [[tablename]] block becomes one element in the JSON array. Two [[servers]] blocks produce "servers": [{...}, {...}] in JSON. This is TOML's equivalent of a JSON array of objects.
Does TOML support null values?
TOML v1.0 has no null type. When converting TOML to JSON, missing keys simply do not appear — there are no explicit null fields unless your converter emits them for missing optional keys. Handle this downstream by using optional chaining or default values.
How do I parse Cargo.toml and get JSON output in Node.js?
Use @iarna/toml: const toml = require('@iarna/toml'); const fs = require('fs'); console.log(JSON.stringify(toml.parse(fs.readFileSync('Cargo.toml','utf8')), null, 2)). Install with npm install @iarna/toml.
If jsondecode.com saved you time, share it with your team
Free forever. No ads. No sign-up. Help other developers find it.