toonlite is a lightweight, dependency-free Python library for encoding and decoding TOON Lite, a simple, human-friendly structured text format similar to JSON/YAML — but much easier to read and write.
It is the Python counterpart to your TOON Lite PHP library.
-
🚀 Simple API:
loads()anddumps() -
📄 Clean, indentation-based structure (like YAML but simpler)
-
🧱 Supports:
- Key–value pairs (
key: value) - Nested objects via indentation
- Lists using
key: []+- item - Scalars: integers, floats, booleans, null, and strings
- Key–value pairs (
-
🔧 Zero dependencies
-
🧪 Fully tested
-
📦 Packaged and ready for PyPI
Once published on PyPI:
pip install toonliteIf installing from TestPyPI:
pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple toonlitefrom toonlite import loads, dumps
text = """
name: Manoj
age: 26
address:
city: Bengaluru
zip: 560001
skills: []
- Python
- PHP
active: true
"""
# Decode TOON Lite → Python dict
data = loads(text)
print(data)
# {
# 'name': 'Manoj',
# 'age': 26,
# 'address': {'city': 'Bengaluru', 'zip': 560001},
# 'skills': ['Python', 'PHP'],
# 'active': True
# }
# Encode Python dict → TOON Lite
encoded = dumps(data)
print(encoded)
"""
name: Manoj
age: 26
address:
city: Bengaluru
zip: 560001
skills: []
- Python
- PHP
active: true
"""Install dependencies:
pip install -e .
pip install pytestRun the test suite:
pytesttoonlite/
├─ src/toonlite/
│ ├─ __init__.py
│ ├─ encoder.py
│ ├─ decoder.py
│ └─ exceptions.py
├─ tests/
│ └─ test_basic.py
├─ pyproject.toml
├─ README.md
├─ LICENSE
└─ .gitignore
name: Alice
age: 30
address:
city: Bengaluru
zip: 560001
skills: []
- Python
- ML
true,falsenull123,3.14"strings"(no quotes necessary unless needed)
Editable install:
pip install -e .Rebuild wheel + sdist:
python -m buildThis project is licensed under the MIT License.
See the LICENSE file for details.
Contributions are welcome! Open an issue or submit a pull request on GitHub.