← All notes

JSON Schema arrays and strings, and what local grammars support

Answer: For list validation, set items to a single schema used to validate all items. For tuple validation, use prefixItems, where each item is a schema corresponding to an index in the array. Set array length with minItems/maxItems and uniqueness with uniqueItems: true. For strings, minLength/maxLength set length and pattern applies a regular expression.

The pattern gotcha

A pattern matches anywhere within the string, so "p" matches "apple". Surround the expression with ^...$ unless there is a good reason not to.

llama.cpp JSON Schema limits

llama.cpp converts only a subset of JSON Schema to GBNF. The documentation lists these limits:

See also

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: json-schema-org/website (GitHub), Understanding JSON Schema: array, BSD-3-Clause (https://raw.githubusercontent.com/json-schema-org/website/main/LICENSE). Copyright (c) 2022 JSON Schema Specification Authors; json-schema-org/website (GitHub), Understanding JSON Schema: string, BSD-3-Clause (https://raw.githubusercontent.com/json-schema-org/website/main/LICENSE). Copyright (c) 2022 JSON Schema Specification Authors; ggml-org/llama.cpp (GitHub), GBNF guide (llama.cpp grammars README), MIT (https://raw.githubusercontent.com/ggml-org/llama.cpp/master/LICENSE). Copyright (c) 2023-2026 The ggml authors. Text was condensed and changed from the originals.

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: json-schema-org/website (GitHub), Understanding JSON Schema: array, BSD-3-Clause (https://raw.githubusercontent.com/json-schema-org/website/main/LICENSE). Copyright (c) 2022 JSON Schema Specification Authors; json-schema-org/website (GitHub), Understanding JSON Schema: string, BSD-3-Clause (https://raw.githubusercontent.com/json-schema-org/website/main/LICENSE). Copyright (c) 2022 JSON Schema Specification Authors; ggml-org/llama.cpp (GitHub), GBNF guide (llama.cpp grammars README), MIT (https://raw.githubusercontent.com/ggml-org/llama.cpp/master/LICENSE). Copyright (c) 2023-2026 The ggml authors.

Cite this

Permanent ID: iil:note:t2fy47gj

iinventedlight. 2026. "JSON Schema arrays and strings, and what local grammars support." iinventedlight Library, iil:note:t2fy47gj, version of 2026-11-16. https://iinventedlight.com/library/notes/ao-structured-json-schema-arrays-and-strings/. License: CC-BY-4.0.

@misc{iil_note_t2fy47gj,
  author = {{iinventedlight}},
  title = {{JSON Schema arrays and strings, and what local grammars support}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-16},
  url = {https://iinventedlight.com/library/notes/ao-structured-json-schema-arrays-and-strings/},
  note = {Permanent ID iil:note:t2fy47gj. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).

For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/ao-structured-json-schema-arrays-and-strings.md.