Overview
The TOON JSON Converter automatically detects the conversion direction based on file extensions, supporting four bidirectional conversion modes:JSON → TOON
Single file conversion from JSON to TOON format
JSONL → Folder
Batch conversion from JSONL to multiple TOON files
TOON → JSON
Single file conversion from TOON to JSON format
Folder → JSONL
Batch conversion from multiple TOON files to JSONL
Mode 1: JSON → TOON
Convert a single JSON file to TOON format.Basic Usage
Automatic Output Path
If you omit the output path, it automatically generatesinput.toon:
Example Conversion
Input:users.json
users.toon
With Options
users.toon
Implementation Details
Source code reference:toon_json_converter.py:1084-1088
Mode 2: JSONL → TOON Folder
Convert each line in a JSONL file to a separate TOON file in a folder.Basic Usage
Automatic Output Path
If you omit the output path, it creates a folder named{filename}_toons:
Example Conversion
Input:logs.jsonl
logs_toons/ with three files:
logs_0000.toon:
logs_0001.toon:
logs_0002.toon:
File Naming Convention
Files are named using the pattern:{base_name}_{index:04d}.toon
base_name: Original filename without extensionindex: Zero-padded 4-digit index (0000, 0001, 0002, …)
Error Handling
The converter skips invalid lines and reports errors: Input:mixed.jsonl
Implementation Details
Source code reference:toon_json_converter.py:1100-1121
The converter:
- Creates the output directory if it doesn’t exist
- Processes each non-empty line
- Generates sequential filenames with zero-padding
- Reports success count and any errors
Mode 3: TOON → JSON
Convert a single TOON file to JSON format.Basic Usage
Automatic Output Path
If you omit the output path, it automatically generatesinput.json:
Example Conversion
Input:config.toon
config.json
With Options
Compact Output
config.json (single line)
Custom Indentation
config.json
Expand Dotted Paths
Input:dotted.toon
dotted.json
Implementation Details
Source code reference:toon_json_converter.py:1090-1094
Mode 4: TOON Folder → JSONL
Convert all TOON files in a folder to a single JSONL file.Basic Usage
Automatic Output Path
If you omit the output path, it creates{folder_name}.jsonl:
Example Conversion
Input folder:events/
event_0000.toon:
event_0001.toon:
event_0002.toon:
events.jsonl
File Processing Order
TOON files are processed in alphabetical order (viasorted()). This ensures deterministic output.
Source code reference: toon_json_converter.py:1124
Error Handling
The converter skips invalid files and reports errors: Terminal output example:Empty Folder Handling
If the folder contains no.toon files:
Implementation Details
Source code reference:toon_json_converter.py:1123-1146
The converter:
- Scans for all
.toonfiles in the directory - Sorts files alphabetically for consistent output
- Parses each TOON file and writes as a single JSON line
- Handles various error types (file read, parse, unexpected)
- Reports summary with success/error counts
Mode Detection Logic
The converter automatically detects the mode using this logic: Source code reference:toon_json_converter.py:1060-1078
Comparison Matrix
| Mode | Input | Output | Use Case |
|---|---|---|---|
| 1. JSON → TOON | Single .json file | Single .toon file | Convert one JSON file to human-readable format |
| 2. JSONL → Folder | Single .jsonl file | Folder of .toon files | Split a line-delimited JSON file into separate records |
| 3. TOON → JSON | Single .toon file | Single .json file | Convert TOON to machine-readable JSON |
| 4. Folder → JSONL | Folder of .toon files | Single .jsonl file | Aggregate multiple TOON files into one dataset |
Next Steps
Options Guide
Learn about all command-line options in detail
Batch Conversion
Master batch processing workflows
CLI Reference
Complete command-line interface reference
TOON Format
Understand the TOON format specification