mini-format 1.1 — build your toolkit from JSON samples get started →

1.1 Your JSON. Your contract. Your .mini. →

LLM outputs that validate themselves.

Provide JSON samples from your domain. mini-format builds your contract, prompt and tools to recover validated JSON from compact AI responses. Detect errors and apply safe repairs with a verifiable report.

Install mini-format 1.1.0

pip install https://mini-format.pmoluna.com/downloads/mini_format-1.1.0-py3-none-any.whl
Read the installation guide ↗

Python 3.9+ · dependency-free core · MIT open source. The ZIP includes the Python package, TypeScript, examples and documentation.

Build my first .mini →

DummyJSON products

194 records · Public test data

Output tokens relative to .mini · lower is better. o200k_base

mini-formatmini-domain/11.00×
CSVflat1.05×
TOONflat1.07×
JSONcompact1.39×
TOONoriginal1.46×
YAML1.21.56×
XMLelements2.65×
6.11% fewer tokens than flat TOON. Includes document metadata and dictionaries; reusable prompt measured separately.method →

For your application

PythonTypeScriptJavaScript

Four tools, designed together.
Use one, or all of them.

mini validate and parse() fit into an existing Python or Node project. Keep your model provider and your framework.

Specification

contract rules · generated prompts

EBNF grammar, 15 stable error codes and an extension protocol. The specification comes before the code and resolves differences between implementations.

$ mini prompt log --lang es

Libraries

parsing · validation · diagnostics

Python and TypeScript, written independently from the same specification. Parser, serializer, lenient mode, prompt block and streaming reader.

$ mini build samples.json --prefix app --out .mini

CLI

build · convert · validate

Build your toolkit, validate, diagnose, convert both ways, generate prompts, count tokens and check families.

$ mini diagnose respuesta.mini

Conformance

shared expectations across implementations

303 language-independent cases, with expectations derived from the specification rather than calculated by the code. Python and TypeScript pass 303/303.

$ python conformance/run_python.py

One minute with mini-format

From contract
to typed
records.

Define, instruct, call, validate, repair and use with the same toolkit. Each step is a real command; output is abbreviated. Pick a step or watch.

~/proyecto — mini01 / 06

      
Reproducible toolkit walkthrough. Output abbreviated for readability. Hover to pause.

One build per domain

Your samples.
Your .mini.

Gather the JSON your application needs. One command creates a .mini directory to reuse in your workflow.

  • Your domain contract. Infer structure, types and optional fields from multiple samples.
  • Prompt and parser. Spanish and English instructions plus executable tools to recover JSON.
  • Validation and repair. Detect the problem, fix unambiguous issues and prepare retries for what needs the model.
  • Better coverage, better contract. Include representative examples, null values, lists and uncommon cases.
mini build phones.json more.json --prefix phone --out .mini
From JSON to your toolkit0:00 / 0:24

        

Watch the workflow video · 24 s

Recording of this demonstration. Real commands; abbreviated output.

Django integration0:00 / 0:26

          

Integration

Fits Django, FastAPI, Express, Next.js and your existing stack.

Load the family registry, request the prompt block with spec_block(), call your provider as usual and pass the response to parse().

servicios/evaluacion.pypython
from minifmt import Registry, parse, spec_block

reg = Registry.load()                     # descubre forks/*/contract.json
c = reg.get("a")

def generar_items(tema):
    respuesta = cliente.completar(sistema=spec_block(c, lang="es"), usuario=tema)
    doc = parse(respuesta, c, strict=False)      # tolerante: acumula errores
    return doc.records, doc.errors                # válidos tipados, rechazados con código

More fields,
greater savings.

JSON repeats every field name in every object. mini-format declares it once in the contract. Field-name cost grows as O(W·N) in JSON and O(W) here.

3 fields

narrow record

savings32.2 %
20 fields

typical business record

savings46.7 %
50 fields

wide record

savings49.3 %

Savings versus compact JSON · linear scale from 0%, maximum 50% · 1,000 records · o200k_base · median of 5 documents per cell · deterministic synthetic data (seed 20260915). The curve levels off near 32 fields. reproduce →

Same data.
Measured token savings.

1,902 records from four public datasets. 35.64% fewer tokens than compact JSON and 9.65% fewer than flat TOON across the measured total.

Output tokens, savings and reusable prompt cost
DatasetN.miniTOON flatSaved vs TOONSaved vs CSV.mini prompt
DummyJSON products19464,09068,2606.11 %4.42 %1,206
DummyJSON users20843,26860,92628.98 %27.92 %1,796
JSONPlaceholder comments50030,26831,0222.43 %-1.35 %477
USGS earthquake observations1,000164,137173,8035.56 %4.11 %1,336

USGS: 1,000 real observations. DummyJSON and JSONPlaceholder: 902 synthetic test records, never duplicated to inflate the batch. Exact JSON round-trips for all eight formats. Official TOON 4.1.1; the smaller of two reversible flattening variants is selected. Savings describe output tokens; the .mini prompt is shown separately. CSV remains smaller for comments. This measures serialization, not LLM generation accuracy. Method and reproduction → · JSON

The same document
has a different cost in each model.

Separators tokenize differently across vocabularies. Same 14 domains, batches of 10, versus compact JSON.

r50k_base

50k vocabulary

savings30.2 %

95% CI [26.8 % · 31.5 %] · k=14

cl100k_base

100k vocabulary

savings32.2 %

95% CI [29.1 % · 33.5 %] · k=14

o200k_base

200k vocabulary

savings34.1 %

95% CI [31.5 % · 35.5 %] · k=14

Linear scale from 0%, maximum 36%: a 3.9-point difference between the oldest and newest vocabulary. All three are tiktoken vocabularies. reproduce →

Interface

Everything comes
from the contract.

pythonminifmt 1.1.0
from minifmt import Registry, parse, dumps, spec_block, roundtrip_ok

reg = Registry.load()                       # descubre forks/*/contract.json
c = reg.get("log")

instruccion = spec_block(c, lang="es")      # bloque para el prompt de sistema
doc = parse(respuesta, c, strict=False)     # tolerante: no lanza, acumula

doc.records                                 # registros válidos, ya tipados
for e in doc.errors:                        # MiniError: code, line, field, message
    print(e)

texto = dumps(doc.to_canonical(), c)          # canónico -> .mini
assert roundtrip_ok(doc.to_canonical(), c)

Playground

Contract, data
and output together.

  1. Choose a family or design one in the wizard.
  2. Paste the model response into the editor for live validation.
  3. Compare tokens against JSON, YAML, XML, CSV and the official TOON encoder.

Runs entirely in your browser with the reference JavaScript port. No server or account required.

Open the playground
Playground · looping walkthrough0:00 / 0:24

        

Comparison

What each format does
when a model writes the output.

Capabilitymini-formatJSONCSVTOON
Fewer tokens than compact JSON
Contract-declared typespartialpartial
Errors with code, line and fieldpartial
Stable specification error codes15
Truncation recoverypartial
Selective per-line repair
Record-by-record streamingpartial
Published conformance suite303
Two independent implementationspartial
Lists with a selected item
Declared forward compatibility
Arbitrary nesting
Reading without a contractpartial
Native provider API support

Forward compatibility preserves known fields when the same prefix declares a higher version. The base profile uses flat records; the generated toolkit reconstructs your domain's JSON structure. The model needs the prompt; the reader needs the contract.

Start with your data.

Download the toolkit, gather JSON samples and build your application's contract.

mini build phones.json --prefix phone --out .mini

Documentation · Specification 1.0 · Error index · Playground