sniff-schema
Infer schema from any JSON or CSV — instantly output as TypeScript, Pydantic, or Markdown.
You get a JSON file or CSV from an API, a colleague, or a legacy system. No docs. No types. Just raw data. sniff-schema reads it and tells you exactly what's in it — field names, types, nullability, null percentages, and sample values — then outputs a ready-to-use TypeScript interface or Pydantic model.
No LLM. No cloud. No auth. Pure local analysis.
Install
pip install sniff-schema
Or run directly without installing:
pip install httpx "rich>=13" "typer>=0.12"
python sniff_schema.py data.json
Usage
# Rich terminal table (default)
sniff-schema data.json
# TypeScript interface
sniff-schema data.json --format typescript
# Pydantic v2 model
sniff-schema data.json --format pydantic
# Markdown table — save to file
sniff-schema data.json --format markdown --output schema.md
# Pipe directly from curl
curl https://api.example.com/users | sniff-schema - --format typescript
# CSV works too
sniff-schema report.csv --format pydantic
# Large files — sample just 100 rows
sniff-schema big_dataset.csv --sample 100
What it detects
| Thing | How |
|---|---|
| Integers, floats, booleans, strings | Native Python types |
| ISO 8601 dates / datetimes | Regex match (2024-01-15, 2024-01-15T10:30:00Z) |
| Numeric strings, boolean strings | Pattern matching on string values |
| Nullable fields | Counts null, missing keys, and empty strings |
| Mixed types | Flags when a field contains more than one type |
| Nested JSON | Flattens to dot-notation (user.address.city) |
| JSON arrays | Handles root arrays, wrapped arrays (data, results, items) |
| NDJSON / JSON Lines | Auto-detected line-by-line |
| CSV dialect | Auto-sniffed (comma, tab, pipe, etc.) |
Output formats
--format typescript
interface InferredSchema {
id: number;
name: string;
age?: number | null;
email?: string | null;
score?: number | null;
active: boolean;
created_at: string;
country: string;
notes?: string | null;
}
// Inferred from 5 record(s)
--format pydantic
from pydantic import BaseModel
from typing import Optional
class InferredSchema(BaseModel):
id: int
name: str
age: Optional[int] = None
email: Optional[str] = None
score: Optional[float] = None
active: bool
created_at: str
country: str
notes: Optional[str] = None
# Inferred from 5 record(s)
--format markdown
Outputs a GitHub-flavored Markdown table — paste directly into your wiki, Notion, or PR description.
All options
Arguments:
SOURCE Path to JSON/CSV file, or '-' to read from stdin.
Options:
-f, --format [table|typescript|pydantic|markdown] Output format (default: table)
-s, --sample Max records to sample (default: 200, max: 100000)
-o, --output Write output to a file instead of stdout
--help Show this message and exit.
Development
git clone https://github.com/gitwingo/sniff-schema
cd sniff-schema
pip install -e ".[dev]"
Support
If sniff-schema has been useful to you, consider supporting its development:
Connect
- GitHub: @gitwingo
- Reddit: u/gitwingo
- X / Twitter: @gitwingo
License
MIT © gitwingo
Metadata
Release files for sniff-schema 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| sniff_schema-0.1.3.tar.gz | 99.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sniff_schema-0.1.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 108.3 kB
Release files / sniff_schema-0.1.3.tar.gz
| Download URL | sniff_schema-0.1.3.tar.gz |
|---|---|
| Size | 99.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f8fd070e797650a456ccf430da31a4718583f5b3094f1e79df9d4859617bac3f
|
|
BLAKE2b-256 checksum How to use checksums |
b6bd0a540e9dc7bef9b090988d3350094be97c670e530431032c233f1a9a4ac3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 3, 2026.
Transparency logRelease files / sniff_schema-0.1.3-py3-none-any.whl
| Download URL | sniff_schema-0.1.3-py3-none-any.whl |
|---|---|
| Size | 8.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
193b3a9accf302bb6f90145a0f34a247e8953639c100d59087deb7f4cdf3fba5
|
|
BLAKE2b-256 checksum How to use checksums |
a91ed33adb7b2df63020abd53066f55e753e6a5804259b97f02844608ef45b06
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 3, 2026.
Transparency log