Chat answers from a local model are fine to read. They are bad input for a script. One reply has a list, the next has a paragraph, and your parser breaks. Ollama on the Mac has a fix for this. It is the format field. Give it json, or give it a full JSON schema, and the reply comes back in that shape.
This tip assumes Ollama already runs on your Mac. If not, start with our Ollama setup on Apple silicon. The examples use the small llama3.2 model. Pull it first with ollama pull llama3.2.
JSON mode in the ollama run command
The fastest test is in Terminal. ollama run has a --format flag. In the help text it is listed as "Response format (e.g. json)".
ollama run llama3.2 --format json "List three Mac apps for notes. Use the key apps."
Inside an open chat session, type /set format json. To go back to normal text, /set noformat. JSON mode only promises valid JSON. It does not promise your key names. Ask for the keys in the prompt too.
Send a JSON schema to /api/chat
For fixed keys, use the local API on port 11434. Put a schema object in format. This is close to the example in Ollama's structured outputs doc:
curl -X POST http://localhost:11434/api/chat -H "Content-Type: application/json" -d '{
"model": "llama3.2",
"messages": [{"role": "user", "content": "Tell me about Canada."}],
"stream": false,
"format": {
"type": "object",
"properties": {
"name": {"type": "string"},
"capital": {"type": "string"},
"languages": {"type": "array", "items": {"type": "string"}}
},
"required": ["name", "capital", "languages"]
}
}'
The JSON sits in message.content of the reply, as a string. Parse it on your side. The doc gives one more hint. Also paste the schema into the prompt as text, so the model is grounded on what you want.

Python with Pydantic
In Python, the ollama package on PyPI already depends on pydantic. So one pip install ollama in a venv covers both. Write a class, pass its schema, then validate:
from ollama import chat
from pydantic import BaseModel
class Note(BaseModel):
title: str
due: str | None
tags: list[str]
r = chat(
model="llama3.2",
messages=[{"role": "user", "content": "Dentist Monday 9am, bring insurance card"}],
format=Note.model_json_schema(),
options={"temperature": 0},
)
print(Note.model_validate_json(r.message.content))
If validation fails, you get an error in your code. Not a quiet wrong value. The doc suggests temperature 0 for more steady results, as above.
Images, the OpenAI route, and the cloud
Vision models take the same format field. The doc's vision example uses gemma4 and returns objects, colors and a scene label as JSON. Our screenshot tip with a local vision model shows the image part. Add a schema on top and the description becomes data.
Apps that talk to Ollama through its OpenAI-compatible API can ask with response_format instead. Ollama's compatibility page lists it as supported.
One limit. Ollama's doc says its cloud does not support structured outputs right now. Run the model locally. If you already turned off Ollama cloud models, nothing changes. The prompt, the schema and the answer stay on the Mac.
Photo: Apple
Source: Ollama docs (Structured Outputs, OpenAI compatibility); ollama/ollama on GitHub (cmd/cmd.go, cmd/interactive.go); ollama on PyPI; Apple Newsroom (Mac mini with M6 and M5 Pro, August 25, 2026)