ollama-json-fixer-python
Force local Ollama models to output strict, valid JSON. Zero dependencies beyond requests.
Problem
Local LLMs (Llama 3, Mistral, Qwen, Codellama) often wrap JSON in conversational text or markdown fences, breaking json.loads(). This causes JSONDecodeError in production pipelines.
Solution
- Auto-strips markdown fences
- Regex extraction of JSON blocks
- Auto-retry with strict system prompt
- Works with ANY Ollama model
- Single file - just copy and use
Quick Start
pip install requests
python ollama_json_fixer.py
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ollama_json_fixer-0.1.0.tar.gz.
File metadata
- Download URL: ollama_json_fixer-0.1.0.tar.gz
- Upload date:
- Size: 3.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.10.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eead9f4b75e92c7de5e12a17436a058363bc105f44f95f999e2a38d2b247c195
|
|
| MD5 |
dd7d7400be31c910eec5c81402259a89
|
|
| BLAKE2b-256 |
a76cbf5d6af7a7c9bcc748476b017d18c687e0da8e5ff97ba5223268b28d7f30
|
File details
Details for the file ollama_json_fixer-0.1.0-py3-none-any.whl.
File metadata
- Download URL: ollama_json_fixer-0.1.0-py3-none-any.whl
- Upload date:
- Size: 3.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.10.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5d946defcb8666a437fc00b99bec517c24daa439d4e8f52c361aaccc05da34e1
|
|
| MD5 |
4ba0ca09814380116ebc5dc3215e2e96
|
|
| BLAKE2b-256 |
cff77c8fe96e1a1369501a4cd300accae7051e0a25a13ccbcbd55dda656aef9a
|