Structure-Aware Tokenization for JSON
Abstract
We present json-tokenizer, a structure-aware tokenizer that assigns dedicated single tokens to JSON grammar elements, learns a compact key vocabulary from training data, and applies byte-pair encoding (BPE) only to value content. General-purpose subword tokenizers such as cl100k_base treat JSON as flat text, splitting structural syntax characters across multiple tokens and re-encoding identical key names in every object. On schema-repetitive JSON workloads -- including GeoJSON features, observability telemetry, and Kubernetes manifests -- json-tokenizer achieves 5-15% token savings over cl100k_base while using a vocabulary approximately 90x smaller (1,100–4,100 tokens vs. 100,256). Batch encoding of JSON arrays yields savings up to 9.3%. All encodings are lossless: decoded output is byte-identical to the original JSON across 4,200+ test objects. Results are stable across five random seeds (standard deviation
Fields of Study & Subjects
Natural Language Processing Techniques
Topic Modeling
Algorithms and Data Compression
Publication details
- Journal / source
- Zenodo (CERN European Organization for Nuclear Research)
- Publication date
- 5 March 2026
- Language
- EN
- Document type
- Preprint