Overview
The TOON JSON Converter provides a simple command-line interface that automatically detects the conversion direction based on file extensions.Basic Syntax
Input file or folder path. The file extension determines the conversion direction:
.json- Converts to TOON format.jsonl- Converts to folder of TOON files.toon- Converts to JSON formatfolder/- Converts all TOON files to JSONL
Output file or folder path. If omitted, automatically generates output path based on input:
data.json→data.toondata.jsonl→data_toons/data.toon→data.jsondata_folder/→data_folder.jsonl
Conversion Modes
The converter supports four bidirectional conversion modes:1. JSON to TOON
2. JSONL to TOON Folder
3. TOON to JSON
4. TOON Folder to JSONL
Command-Line Options
General Options
Specify output file or folder path. Alternative to using positional argument.
Encoding Options (JSON → TOON)
These options apply when converting FROM JSON or JSONL TO TOON:Use tab (Example output:
\t) as the delimiter for tabular arrays instead of comma.Default: Comma (,)Line reference: toon_json_converter.py:1215-1216Use pipe (Example output:
|) as the delimiter for tabular arrays instead of comma.Default: Comma (,)Line reference: toon_json_converter.py:1217-1218Add Example output:
# prefix to array lengths in headers for improved readability.Default: No prefixLine reference: toon_json_converter.py:1219-1220Enable key folding for nested single-key objects. Converts chains like Example transformation:Becomes:
{"a": {"b": {"c": value}}} to a.b.c: value.Default: DisabledLine reference: toon_json_converter.py:1221-1222Requirements: Keys must match pattern [A-Za-z_][A-Za-z0-9_]*Decoding Options (TOON → JSON)
These options apply when converting FROM TOON TO JSON or JSONL:Output minified JSON without whitespace or indentation.Default: Pretty-printed with 2-space indentationLine reference: toon_json_converter.py:1228-1229Example output:
Set the number of spaces for JSON indentation.Default: Example output:
2Line reference: toon_json_converter.py:1232-1238Expand dotted keys into nested objects during TOON → JSON conversion.Default: Disabled (per TOON spec §13.4)Line reference: toon_json_converter.py:1230-1231Example transformation:TOON input:Without With
--expand-paths (default):--expand-paths:Exit Codes
The converter returns the following exit codes:| Code | Meaning |
|---|---|
0 | Success |
1 | Error (missing arguments, file not found, conversion error) |
Examples
Convert with Custom Delimiter
Convert with Multiple Options
Convert to Compact JSON
Batch Convert with Custom Output
Help Command
Run the converter without arguments to display usage information:Next Steps
Conversion Modes
Learn about all four conversion modes in detail
Options Guide
Deep dive into all command-line options
Batch Conversion
Process multiple files efficiently
Quick Start
Get started with basic examples