Skip to main content

A utility package to convert JSON data to multiple formats like XML, Markdown, CSV, etc.

Project description

Json2Many

PyPI Version License

A zero-dependency Python library and CLI for converting JSON into multiple output formats. Every conversion returns a typed ConversionResult — no raw string parsing, full mypy/pyright support out of the box.

User Guide — scenario-driven walkthrough of every feature

demo


Installation

# Library only
pip install json_to_many

# With CLI support
pip install 'json_to_many[cli]'

Quick Start

Library:

from json_to_many import convert

result = convert("users.json", "csv", delimiter=";")
print(result.data)
# id,name,email,score,city
# 1,Alice Nguyen,alice@example.com,8.4,London
# 2,Bob Smith,bob@example.com,7.1,Berlin
print(result.stats.rows)    # 5

CLI:

# Inspect a JSON file before converting
json2many schema api_export.json

# Convert to CSV
json2many convert api_export.json --to csv --output report.csv

# Multiple formats in one pass
json2many convert api_export.json --to csv --to html --output-dir ./dist/

Formats

Format When to use Options
markdown Docs, wikis, changelogs title, heading_offset, max_heading_level, bullet_lists, table_for_lists, frontmatter, code_block_keys
xml Legacy system integration, data exchange root_element, item_element, pretty_print
csv Spreadsheets, analyst handoff delimiter, quotechar, include_header, columns
html Stakeholder reports, CI build artifacts title, table_style, wrap_in_page
jsonl Log pipelines, ML fine-tuning, streaming ensure_ascii
sql Database seeding, fixture data for tests table, include_create, batch_size

Project Config

Add .json2many.toml at your project root to share converter settings across a team:

[converters.csv]
delimiter = ";"

[converters.xml]
pretty_print = true
root_element = "records"

Explicit options always override the config file. See the User Guide for the full priority order and all supported keys.


Development

uv sync --extra cli --dev       # install runtime, CLI, and dev tooling
uv run pre-commit install       # install Git hooks
uv run pre-commit run --all-files
uv run pytest

The pre-commit setup runs Ruff lint fixes, Ruff formatting, YAML validation, trailing whitespace cleanup, and final newline checks. Ruff is pinned through both pyproject.toml and .pre-commit-config.yaml; keep those versions aligned when upgrading the formatter.

Maintainers: See RELEASING.md for the release process.

License

MIT — see LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

json_to_many-0.4.0.tar.gz (14.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

json_to_many-0.4.0-py3-none-any.whl (24.8 kB view details)

Uploaded Python 3

File details

Details for the file json_to_many-0.4.0.tar.gz.

File metadata

  • Download URL: json_to_many-0.4.0.tar.gz
  • Upload date:
  • Size: 14.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.4

File hashes

Hashes for json_to_many-0.4.0.tar.gz
Algorithm Hash digest
SHA256 d33b29592ba961bf6d97660c1afdd8384c5b7207911474301ca5f28584e1feff
MD5 55d819c5d767f036b29c25c4e67f7525
BLAKE2b-256 24b171a1ca29faddf4264a2059b9fd956e977d82ee638c34ae112b17891bedcc

See more details on using hashes here.

File details

Details for the file json_to_many-0.4.0-py3-none-any.whl.

File metadata

File hashes

Hashes for json_to_many-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1e561a30b51ccb8abb09724d8acf79983277df9d876c535767f61cc0a362d14b
MD5 f20156c79845a9a97097da5af9560f58
BLAKE2b-256 39ec8985ed5a5dbea38e5afc16636ce265baa5ac7233ff0bffbaa01e94c2e701

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page