stanio
Utilities for preparing Stan inputs and processing Stan outputs
What it is and what it does
StanIO is a data-wrangling utility for the Stan probabilistic programming language, handling the format conversions needed between Python and Stan. It writes Python dictionaries to Stan-compatible JSON and reads Stan's CSV output format back into numpy arrays, automatically reshaping parameters according to their declared dimensions in Stan programs.
The package is primarily designed as a supporting library for cmdstanpy, the Python interface to Stan. It solves the practical problem of moving data in and out of Stan workflows without manual format handling. With numpy as its only runtime dependency and Python 3.8+ support, it integrates cleanly into existing scientific Python stacks.
Use it for:
- Prepare input data dictionaries for Stan models by converting them to Stan-compatible JSON format
- Parse Stan CSV output files into numpy arrays with automatic parameter reshaping based on Stan declarations
- Extract multi-dimensional parameters from Stan output with correct shape inference
- Integrate Stan probabilistic models into Python data analysis pipelines
- Serialize Python data structures for use in Stan programs without manual JSON construction
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
StanIO converts Python dictionaries to Stan-compatible JSON and reads Stan CSV output files into numpy arrays, extracting parameters according to Stan program structure.
Yes, if you use Stan or cmdstanpy in Python. The package has low install friction, no known vulnerabilities, permissive licensing, and active maintenance. It solves a specific but essential problem for Stan workflows. Not relevant for projects that don't use Stan.
Install
stanio on PyPI
pip
pip install staniouv
uv add staniopoetry
poetry add stanioInstalling stanio
Before you install
Low friction install with a single runtime dependency (numpy). Actively maintained with recent commits; Beta status indicates ongoing development but stable enough for use.
License in practice
BSD-3-Clause permissive license allows commercial and private use with minimal restrictions beyond attribution and liability disclaimer.
Quickstart
pip install stanio
import stanio
import numpy
# Convert Python dict to Stan JSON
data = {'x': [1, 2, 3]}
stanio.write_stan_json('input.json', data)
# Read Stan CSV output into numpy array
draws = stanio.read_stan_csv('output.csv')
Requires Python 3.8 or later; numpy must be installed as a runtime dependency.
Verify before relying
- Whether ujson integration (mentioned as optional) is automatically available or requires separate installation
- Performance characteristics when handling large Stan output files or high-dimensional parameter arrays
Package facts
| License | BSD-3-Clause (permissive) |
| Python support | supports the current Python release (>=3.8) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — numpy |
| Maintenance | actively maintained — 767 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 5,998,007/month — #1,991 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: stanio-0.5.1-py3-none-any.whl
Tags
More Scientific/Engineering packages
NumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
pandaspandas provides fast, flexible data structures…
permissive · top 100 on PyPI
scipyscipy provides numerical algorithms for…
permissive · top 100 on PyPI
scikit-learnscikit-learn provides a comprehensive Python…
permissive · top 1,000 on PyPI
dilldill extends Python's pickle module to…
permissive · top 1,000 on PyPI
multiprocessMultiprocess is an enhanced fork of Python's…
permissive · top 1,000 on PyPI
cmdstanpyCmdStanPy provides a pure-Python interface to…
permissive · top 5,000 on PyPI
pystanPyStan provides a Python interface to Stan for…
permissive · top 5,000 on PyPI
php2jsonConverts PHP serialized strings to JSON format,…
permissive · top 15,000 on PyPI
numpyencoderProvides a custom JSON encoder class that…
permissive · top 15,000 on PyPI
msgpack-numpySerializes and deserializes NumPy arrays and…
permissive · top 5,000 on PyPI
jsonpicklejsonpickle converts complex Python objects to…
permissive · top 5,000 on PyPI
json-tricksExtends Python's JSON serialization to handle…
permissive · top 15,000 on PyPI
json-numpyProvides lossless JSON encoding and decoding…
permissive · top 15,000 on PyPI
httpstanhttpstan provides an HTTP REST interface to the…
permissive · top 5,000 on PyPI
msgpack-numpy-opentensorSerializes and deserializes NumPy arrays and…
permissive · top 15,000 on PyPI