Skip to main content

ISON Logo

ISON CLI

Command-line interface for ISON - Convert, validate, and work with token-efficient data formats.

PyPI version License: MIT

Features

  • Universal Converter - Convert between ISON, JSON, YAML, CSV, TSV, TOML, XML
  • Token Counter - Compare token usage across formats (for LLM cost optimization)
  • Validator - Validate ISON/ISONL syntax
  • Database Export - Export SQL databases to ISON
  • Pretty Printer - Format and view ISON files

Installation

# Basic installation
pip install ison-cli

# With token counting support
pip install ison-cli[tokens]

# With database export support
pip install ison-cli[db]

# Full installation (all features)
pip install ison-cli[all]

Quick Start

# Convert JSON to ISON
ison convert data.json -o data.ison

# Convert ISON to JSON
ison convert data.ison -o data.json

# Compare token counts
ison tokens data.json --compare

# Validate ISON file
ison validate data.ison

# View ISON contents
ison view data.ison

Commands

ison convert - Format Conversion

Convert between any supported formats:

# JSON to ISON
ison convert users.json -o users.ison

# ISON to JSON
ison convert users.ison -o users.json

# CSV to ISON
ison convert data.csv -o data.ison --block users

# YAML to ISON
ison convert config.yaml -o config.ison

# ISON to YAML
ison convert data.ison -o data.yaml

# Output to stdout
ison convert data.json -t ison --stdout

# Compact JSON output
ison convert data.ison -o data.json --compact

Supported Formats:

Format Extensions Description
ison .ison ISON - Token-efficient structured data
isonl .isonl ISON Lines - Streaming format
json .json JSON - JavaScript Object Notation
jsonl .jsonl, .ndjson JSON Lines - Newline-delimited JSON
yaml .yaml, .yml YAML - Human-readable data format
csv .csv CSV - Comma-separated values
tsv .tsv TSV - Tab-separated values
toml .toml TOML - Configuration format
xml .xml XML - Extensible Markup Language

ison tokens - Token Counting

Compare token usage across formats for LLM cost optimization:

# Count tokens in a file
ison tokens data.json

# Compare all formats
ison tokens data.json --compare

# Use specific model tokenizer
ison tokens data.json --compare -m gpt-4

# Raw output (for scripting)
ison tokens data.json --raw

Example output:

┏━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━━━┓
┃ Format           ┃   Tokens ┃    Chars ┃    vs JSON ┃
┡━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━━━━┩
│ ISON             │      386 │    1,245 │    -73.7%  │
│ ISONL            │      412 │    1,380 │    -71.9%  │
│ JSON Compact     │      861 │    2,890 │    -41.3%  │
│ YAML             │    1,124 │    3,450 │    -23.4%  │
│ JSON             │    1,465 │    4,920 │   baseline │
└──────────────────┴──────────┴──────────┴────────────┘

ISON saves 73.7% tokens vs JSON

ison validate - Validation

Validate ISON and ISONL files:

# Validate syntax
ison validate data.ison

# Quiet mode (only show errors)
ison validate data.ison -q

# Strict mode
ison validate data.ison --strict

ison view - View Contents

View and inspect ISON files:

# View with rich formatting
ison view data.ison

# View specific block
ison view data.ison --block users

# View as JSON
ison view data.ison --json

# Limit rows
ison view data.ison -n 10

# Raw output
ison view data.ison --raw

ison fmt - Format/Pretty Print

Format ISON files:

# Format in place
ison fmt data.ison

# Format to new file
ison fmt data.ison -o formatted.ison

# Check if formatted
ison fmt data.ison --check

# Compact output
ison fmt data.ison --compact

ison info - File Information

Show file statistics:

ison info data.ison

Output:

╭─ data.ison ──────────────────────────╮
│ Format: ISON                         │
│ Size: 1,245 bytes                    │
│ Blocks: 2                            │
│ Total rows: 150                      │
│                                      │
│ Blocks:                              │
│   table.users: 100 rows, 5 fields    │
│   table.orders: 50 rows, 4 fields    │
╰──────────────────────────────────────╯

ison export - Database Export

Export SQL databases to ISON:

# List tables
ison export sqlite:///data.db --list-tables

# Export specific table
ison export sqlite:///data.db -t users -o users.ison

# Export multiple tables
ison export sqlite:///data.db -t users -t orders -o data.ison

# Export with SQL query
ison export sqlite:///data.db -q "SELECT * FROM users WHERE active=1" -o active_users.ison

# Export to JSON
ison export sqlite:///data.db -t users -o users.json -f json

# PostgreSQL
ison export postgresql://user:pass@localhost/mydb -t users -o users.ison

# Limit rows
ison export sqlite:///data.db -t users -n 100 -o sample.ison

Supported Databases:

  • SQLite: sqlite:///path/to/db.sqlite
  • PostgreSQL: postgresql://user:pass@host:5432/dbname
  • MySQL: mysql://user:pass@host:3306/dbname
  • SQL Server: mssql+pyodbc://user:pass@host/dbname

ison formats - List Formats

Show all supported formats:

ison formats

Examples

Convert API Response to ISON

# Fetch JSON from API and convert to ISON
curl https://api.example.com/users | ison convert - -t ison > users.ison

CI/CD Validation

# Validate all ISON files in directory
for f in *.ison; do ison validate "$f" -q || exit 1; done

Token Cost Estimation

# Compare formats for a large dataset
ison tokens large_dataset.json --compare -m gpt-4o

# Output for scripting
TOKENS=$(ison tokens data.ison --raw)
echo "Cost estimate: $((TOKENS * 3 / 1000000)) per 1M requests"

Database Migration

# Export entire database
ison export sqlite:///legacy.db -o backup.ison

# Convert to JSON for another system
ison convert backup.ison -o backup.json

Configuration

The CLI respects these environment variables:

Variable Description Default
ISON_DEFAULT_MODEL Default tokenizer model gpt-4o
ISON_OUTPUT_FORMAT Default output format ison

Programmatic Usage

The CLI modules can be used as a library:

from ison_cli.formats import convert, Format

# Convert JSON to ISON
ison_text = convert(json_string, Format.JSON, Format.ISON)

# Compare token counts
from ison_cli.tokens import compare_formats
results = compare_formats(content, Format.JSON, model="gpt-4o")

License

MIT License - see LICENSE for details.

Metadata

Release files for ison-cli 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ison-cli 1.1.0
File Size Uploaded
ison_cli-1.1.0.tar.gz 20.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ison-cli 1.1.0
File Interpreter ABI Platform
ison_cli-1.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 36.5 kB

Release files / ison_cli-1.1.0.tar.gz

Download URL ison_cli-1.1.0.tar.gz
Size 20.0 kB
Tags Source
SHA-256 checksum
How to use checksums
5671a70e3a5b9dcdfccc72def7ef5d445923e01e3a2f7f75eb46c0b777593662
BLAKE2b-256 checksum
How to use checksums
91878ae2057751674feeb02c6c95ed40125445a306c03821883f68a01b12d091
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.16

Release files / ison_cli-1.1.0-py3-none-any.whl

Download URL ison_cli-1.1.0-py3-none-any.whl
Size 16.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c2c2b00d700f8b11af3d59db1a2ffa5e163b32694af85ed3e05ce04b0dfc9d03
BLAKE2b-256 checksum
How to use checksums
15d405d4c86774b91d12a198737c2f857a82bbbe12dbe37590dc640f61a49a18
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.16

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page