Fast, composable command-line utilities for converting, querying, validating, and transforming JSON and related data formats.
JSON Toolkit is a comprehensive suite of command-line utilities designed to make it easy to work with JSON and other data formats. Whether you need to convert data, manipulate it, or extract information, this toolkit has you covered.
- Format conversion: Bidirectional conversion between JSON and CSV, XML, YAML, TOML, HTML, logfmt, environment variables, and more
- JSON manipulation: Format, diff, schema generation, and data transformation
- Database integration: Read from and write to PostgreSQL, MySQL, SQLite3, and Oracle Autonomous Database
- Unix-friendly: All tools follow Unix philosophy—read from stdin, write to stdout, composable with pipes
- Lightweight: Simple utilities with minimal dependencies, designed for scripting and automation
sudo add-apt-repository ppa:code-faster/ppa
sudo apt update
sudo apt install json-toolkit- Bash
- Go (golang-go)
- Python 3
- jq (>= 1.5)
git clone https://github.com/tyleradams/json-toolkit.git
cd json-toolkit
make
make test
sudo make install# Convert CSV to JSON
csv-to-json < data.csv > data.json
# Pretty-print JSON
json-format < data.json
# Compare two JSON files
json-diff file1.json file2.json
# Query PostgreSQL and output as JSON
json-sql read psql user password localhost 5432 mydb
# Convert JSON to YAML
json-to-yaml < config.json > config.yaml
# Generate JSON schema from sample data
json-make-schema < sample.json > schema.jsonAll utilities follow the same pattern:
- Read from stdin (or files where specified)
- Write to stdout
- Return exit code 0 on success, non-zero on failure
- Provide
--helpor-hfor detailed usage
csv-to-json- Convert CSV to JSON arraydsv-to-json- Convert delimiter-separated values to JSONxml-to-json- Convert XML to JSONyaml-to-json- Convert YAML to JSONtoml-to-json- Convert TOML to JSONhtml-to-json- Convert HTML to JSONlogfmt-to-json- Convert logfmt to JSONenv-to-json- Convert environment variables to JSONdiff-to-json- Convert unidiff patches to JSONbinary-to-json- Convert binary data to JSONpython-to-json-ast- Parse Python code to JSON AST
json-to-csv- Convert JSON to CSVjson-to-dsv- Convert JSON to delimiter-separated valuesjson-to-xml- Convert JSON to XMLjson-to-yaml- Convert JSON to YAMLjson-to-env- Convert JSON to environment variable formatjson-to-logfmt- Convert JSON to logfmtjson-to-binary- Convert JSON to binary
json-format- Pretty-print or minify JSONjson-diff- Compare two JSON files and output structured differencesjson-make-schema- Generate JSON schema from input datajson-table-to-objs- Convert JSON table format to objectsjson-objs-to-table- Convert JSON objects to table format
json-sql- Read from or write to SQL databases (PostgreSQL, MySQL, SQLite3, Oracle ADB)
# Read entire database as JSON
json-sql read psql user password localhost 5432 database
# Execute queries from JSON array
echo '["SELECT * FROM users WHERE id = 1"]' | json-sql query psql user password localhost 5432 database
# SQLite example
json-sql read sqlite3 mydata.db
# MySQL example
json-sql read mysql user password localhost 3306 databasejson-run- Execute code based on JSON inputpjito- "Python JSON in, text out" - template rendererjson-to-plot- Generate plots from JSON data
# CSV to JSON, filter with jq, convert to YAML
csv-to-json < users.csv | jq '.[] | select(.active == true)' | json-to-yaml > active-users.yaml
# Read PostgreSQL table, extract specific fields
json-sql read psql user pass localhost 5432 db | jq '.users[] | {id, email}' > user-emails.json
# Compare two configuration files
json-diff config-old.json config-new.json | json-format# Dump entire database to JSON
json-sql read psql postgres password localhost 5432 mydb > backup.json
# Insert data from JSON
echo '["INSERT INTO logs (message, level) VALUES ('"'"'test'"'"', '"'"'info'"'"')"]' | \
json-sql query sqlite3 app.db# Generate schema from sample data
json-make-schema < sample-data.json > schema.json
# Use the schema for documentation or validationAll utilities follow standard exit code conventions:
0- Success1- Runtime or I/O error (file not found, parse error, etc.)2- Usage error (invalid arguments or options)
Some utilities have specialized exit codes (see individual --help for details).
make # Build all components
make clean # Remove build artifactsmake test # Run all tests
./run-json-diff-tests # Test json-diff specifically
./run-all-tests # Complete test suitemake fmt # Format code (Go and Python)
make lint # Run lintersmake install # Install to /usr/local/bin (requires sudo)
make prefix=/custom/path install # Install to custom locationjson-toolkit/
├── src/ # Source files for all utilities
│ ├── *.go # Go programs (json-diff)
│ ├── *-to-json # Python conversion utilities
│ ├── json-to-* # Python output converters
│ └── json-* # JSON manipulation tools
├── test_data/ # Test fixtures and expected results
├── debian/ # Debian packaging files
├── Makefile # Root build configuration
└── README.md # This file
- Python 3
- jq (>= 1.5)
- Go (for json-diff)
The following Python packages are required (automatically installed with the Debian package):
psycopg2-binary- PostgreSQL supportPyMySQL- MySQL supportcx_Oracle- Oracle Database supportPyYAML- YAML format supportxmltodict- XML format supportunidiff- Diff format supportlogfmt- Logfmt format supportgenson- JSON schema generationast2json- Python AST parsing
Contributions are welcome! Here's how to get started:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Run tests (
make test) - Commit your changes (
git commit -m 'Add amazing feature') - Push to your branch (
git push origin feature/amazing-feature) - Open a Pull Request
Please ensure:
- All tests pass
- Code follows existing style (run
make fmtandmake lint) - New utilities include help text and examples
- Documentation is updated
This project uses Semantic Versioning. For available versions, see the releases page.
This project is licensed under the GNU General Public License v2.0 - see the LICENSE file for details.
- Issues: Report bugs or request features on our GitHub Issues page
- Questions: For usage questions, please open a discussion or issue
Special thanks to:
- The jq project for inspiration on composable JSON tools
- All contributors and users who have provided feedback
- The open-source community for the excellent libraries this project builds upon
"the best opensource converter I've found across the Internet" - dene14