---
source: https://iinventedlight.com/library/notes/ao-structured-json-schema-arrays-and-strings.md
title: "JSON Schema arrays and strings, and what local grammars support"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "BSD-3-Clause (json-schema-org/website (GitHub)); BSD-3-Clause (json-schema-org/website (GitHub)); MIT (ggml-org/llama.cpp (GitHub)); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "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."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-16
status: published
approved_by: "Cole Withington, 2026-11-20 13:14 PT: \"Publish the full batch and rewrite the 6 live notes\""
checked_on: 2026-11-16
as_of: 2026-11-16
confidence: medium
untested: "Not reproduced (2026-11-16). Docs read; no API call was made for this note."
category: agent-operations
topic_area: "agent operations: structured output"
tags: [json-schema, arrays, strings, llama-cpp, gbnf]
client: Librarian
sources:
  - id: S1
    title: "Understanding JSON Schema: array"
    publisher: json-schema-org/website (GitHub)
    url: https://github.com/json-schema-org/website/blob/main/pages/understanding-json-schema/reference/array.md
    accessed: 2026-11-16
    license: "BSD-3-Clause"
  - id: S2
    title: "Understanding JSON Schema: string"
    publisher: json-schema-org/website (GitHub)
    url: https://github.com/json-schema-org/website/blob/main/pages/understanding-json-schema/reference/string.md
    accessed: 2026-11-16
    license: "BSD-3-Clause"
  - id: S3
    title: "GBNF guide (llama.cpp grammars README)"
    publisher: ggml-org/llama.cpp (GitHub)
    url: https://github.com/ggml-org/llama.cpp/blob/master/grammars/README.md
    accessed: 2026-11-16
    license: "MIT"
---
# 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:

- `prefixItems` is broken, but `items` works.
- `minimum` and `maximum` are only supported for `"type": "integer"`.
- Patterns must start with `^` and end with `$`; there are no string formats for `uri` or `email`.
- `uniqueItems` and `contains` are unlikely to be implemented.
- Unsupported features are skipped silently.

## See also

- [ao-structured-json-schema-objects](https://iinventedlight.com/library/notes/ao-structured-json-schema-objects/)
- [ao-structured-ollama-and-llamacpp-grammars](https://iinventedlight.com/library/notes/ao-structured-ollama-and-llamacpp-grammars/)
- [ao-structured-across-providers](https://iinventedlight.com/library/notes/ao-structured-across-providers/)
- [ao-structured-gemini-json-schema](https://iinventedlight.com/library/notes/ao-structured-gemini-json-schema/)

## Claims

- id: C1
  claim: uniqueItems requires unique elements.
  source: S1
  evidence: "Simply set the `uniqueItems` keyword to `true`."

- id: C2
  claim: pattern restricts strings by regex.
  source: S2
  evidence: "The `pattern` keyword is used to restrict a string to a particular"

- id: C3
  claim: Unsupported features are skipped silently.
  source: S3
  evidence: "Unsupported features are skipped silently."

## Sources

- [S1] Understanding JSON Schema: array. json-schema-org/website (GitHub). https://github.com/json-schema-org/website/blob/main/pages/understanding-json-schema/reference/array.md . License: BSD-3-Clause. Accessed 2026-11-16.

- [S2] Understanding JSON Schema: string. json-schema-org/website (GitHub). https://github.com/json-schema-org/website/blob/main/pages/understanding-json-schema/reference/string.md . License: BSD-3-Clause. Accessed 2026-11-16.

- [S3] GBNF guide (llama.cpp grammars README). ggml-org/llama.cpp (GitHub). https://github.com/ggml-org/llama.cpp/blob/master/grammars/README.md . License: MIT. Accessed 2026-11-16.

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.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
