flatjson-cli
A fast, memory-efficient deep JSON and JSONL to tabular CSV flattener with schema inspection by Zephyrus Labs for Linux, macOS, and Windows.
Features
- ⚡ Zero External Dependencies: Pure Python standard library implementation.
- 🗂️ Nested Structure Unrolling: Recursively transforms deeply nested objects into flat dot-notation columns (
user.profile.address.city). - 🔄 Multiple Array Handling Strategies:
join: Concatenates list items with semicolons ("admin; editor").index: Unrolls list items into dedicated indexed columns (roles.0,roles.1).explode: Duplicates records for relational unnesting of array items.
- 📊 Streaming & JSONL Support: Streams large
.jsonl/.ndjsonfiles without exhausting system RAM. - 🔍 Token-Saving Schema Discovery: Inspects field names, inferred types, and sample values without generating full CSV files.
- 🧙 Interactive Terminal Wizard: User-friendly interactive mode with file selection, strategy picking, and real-time conversion stats.
Installation
pip install flatjson-cli
Or install the latest development version directly from GitHub:
pip install git+https://github.com/uchiha-fire/flatjson-cli.git
Interactive Mode
Simply run flatjson without arguments or pass --interactive to launch the step-by-step wizard:
flatjson
╔══════════════════════════════════════════════════════════════╗
║ flatjson-cli v0.1.0 ║
║ Deep JSON & JSONL to Tabular CSV Flattener ║
║ Zephyrus Labs (https://zephyrus-labs.tech/) ║
╚══════════════════════════════════════════════════════════════╝
Welcome to the flatjson Interactive Wizard!
Enter path to JSON / JSONL file: telemetry.jsonl
Select Operation:
[1] Flatten to CSV (Standard)
[2] View Schema Summary (Zero CSV generated)
[3] Preview First 5 Flattened Records
Choose [1/2/3] (default: 1): 1
Choose Key Separator:
[1] '.' (e.g., user.address.city) [Default]
[2] '_' (e.g., user_address_city)
[3] Custom delimiter
Choose [1/2/3] (default: 1): 1
Choose Array Strategy:
[1] 'join' - Semicolon-separated string (e.g. 'admin; editor') [Default]
[2] 'index' - Unroll to indexed columns (e.g. roles.0, roles.1)
[3] 'explode' - Duplicate rows for each array item
Choose [1/2/3] (default: 1): 1
Enter output CSV path (default: telemetry.csv): telemetry.csv
Flattening data...
✓ Successfully flattened 12500 records into 34 columns.
✓ CSV saved cleanly to: telemetry.csv
CLI Usage & Options
# Basic conversion (outputs data.csv)
flatjson data.json
# Specify custom destination
flatjson data.json -o ./exports/clean.csv
# Process JSONL streaming data with underscore delimiter
flatjson stream.jsonl -s "_" -a index
# Inspect schema without writing CSV
flatjson complex_dataset.json --schema
Options Reference
| Flag | Long Option | Default | Description |
|---|---|---|---|
input |
(positional) | None | Path to input .json or .jsonl file |
-o |
--output |
<input>.csv |
Destination path for output CSV |
-s |
--sep |
. |
Key delimiter for nesting (. or _) |
-a |
--array-mode |
join |
Array handling strategy (join, index, explode) |
--schema |
False |
Display schema summary without generating CSV | |
-f |
--force |
False |
Overwrite existing output file without confirmation |
-q |
--quiet |
False |
Suppress non-essential progress messages |
-i |
--interactive |
False |
Launch interactive configuration wizard |
-v |
--version |
— | Display package version |
Python API Reference
flatjson-cli can be integrated directly into your Python pipelines:
from flatjson import flatten_record, json_file_to_csv, infer_schema
# 1. Flatten an in-memory dictionary
record = {
"user": {"name": "Alice", "contact": {"email": "alice@example.com"}},
"tags": ["admin", "dev"]
}
flat = flatten_record(record, separator=".", array_strategy="join")
print(flat)
# Output:
# {
# "user.name": "Alice",
# "user.contact.email": "alice@example.com",
# "tags": "admin; dev"
# }
# 2. File-to-file streaming conversion
stats = json_file_to_csv(
input_path="raw_dump.jsonl",
output_path="normalized.csv",
separator=".",
array_strategy="join"
)
print(f"Processed {stats['records']} records into {stats['columns']} columns.")
Developed & Maintained by Zephyrus Labs
Built and maintained with ❤️ by Zephyrus Labs and Lead Developer Shubham Sharma.
- 💼 LinkedIn: linkedin.com/in/shubham-sharma-28487819b
- 💻 GitHub: @uchiha-fire
- 🌐 Website: zephyrus-labs.tech
- ✉️ Organization Email: zephyrus.labs@gmail.com
- 📬 Developer Email: sharmashubham25962@gmail.com
If you find this tool helpful, please give it a ⭐️ on GitHub!
Acknowledgements & Attributions
This tool is built strictly with the Python Standard Library (json, csv, argparse, os, sys). No external runtime dependencies are required.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Lead Developer: Shubham Sharma (@uchiha-fire) • sharmashubham25962@gmail.com
Metadata
Release files for flatjson-cli 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| flatjson_cli-0.1.0.tar.gz | 14.1 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| flatjson_cli-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 25.1 kB
Release files / flatjson_cli-0.1.0.tar.gz
| Download URL | flatjson_cli-0.1.0.tar.gz |
|---|---|
| Size | 14.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6c1e05b89a4529dbef30f07b601d70bb39a1e450c1571e932174a4046cd8f05d
|
|
BLAKE2b-256 checksum How to use checksums |
a7bb7f80757d927a27ef69c7602e36ed7e6ebbf9b195dc6435b51c8d1ad498ad
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.8.10
|
Release files / flatjson_cli-0.1.0-py3-none-any.whl
| Download URL | flatjson_cli-0.1.0-py3-none-any.whl |
|---|---|
| Size | 10.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ebe8f2fe0feade0d0e022a14c8435bd0514777941588b27d966ddea5ac80ddca
|
|
BLAKE2b-256 checksum How to use checksums |
92611c129f26eea401cf5ccfd453f6a55b3b41f28c4865bc0f08f666cc0026ae
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.8.10
|
Security for flatjson-cli 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.