Grammar-valid token
Sampled token
Invalid pick (broken)
⚠ Couldn't load the 3D engineThree.js failed to load from the CDN. Check your connection and reload.
Structured-output tools keep an LLM's JSON valid by walking a finite-state grammar alongside generation and masking every token that would break the schema before the softmax ever runs. This simulator builds a real ten-state automaton for a small {"name": …, "age": …} object, samples tokens step by step from a live 3D bar chart of the masked (or unmasked) next-token distribution, and animates a marker travelling the automaton's state graph as each token is accepted. Toggle constrained decoding off to watch unconstrained sampling occasionally pick a structurally illegal token and break the run — the same failure mode grammar-constrained decoding exists to eliminate — and track the valid-JSON success rate across runs live.