Registry / serialization / nestedtext

nestedtext

JSON →
library3.8pypypi✓ verified 83d ago

Human readable and writable data interchange format, similar to YAML but simpler. Current version 3.8, requires Python >=3.6. Development is active with regular releases.

pip install nestedtext
INSTALL
IMPORT
SIG · NESTEDTEXT
N
nestedtext
serializationpythonv3.8
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

dumps
from nestedtext import dumps
import nestedtext; nestedtext.dumps()
Direct import of functions is more common and idiomatic.
loads
from nestedtext import loads
import nestedtext; nestedtext.loads()
Direct import avoids repeated module prefix.

Basic serialization and deserialization example.

from nestedtext import dumps, loads data = {"name": "Alice", "age": 30, "pets": ["cat", "dog"]} nt_string = dumps(data) print(nt_string) # Output: # name: Alice # age: 30 # pets: # - cat # - dog loaded = loads(nt_string) print(loaded) # {'name': 'Alice', 'age': 30, 'pets': ['cat', 'dog']}
Debug
Known issues
gotchaNestedText does not support all JSON types: numbers are parsed as strings and booleans are not natively supported. Dumping Python int/float will produce strings like '42' or '3.14'.
fix
Use explicit type conversion on load: int(value) to convert strings back to numbers. For booleans, use 'true'/'false' strings and map yourself.
affects: all
gotchaThe format is case-sensitive and strict about indentation. Mixing tabs and spaces or using inconsistent indentation will cause a parse error.
fix
Always use spaces (2 or 4) consistently. Avoid tabs.
affects: all
Errors
Common errors & fixes
nestedtext.errors.NestedTextError: line 1, column 1: expected mapping or indented block
The input starts with a value that is not a key-value mapping (e.g., a scalar or list at top-level). NestedText expects a mapping at top level.
fix
Wrap the top-level value in a dummy key, or ensure the file starts with a key-value pair.
nestedtext.errors.NestedTextError: line 1, column 1: invalid character: ':'
Input contains a bare colon not part of a key-value pair, or the key is missing.
fix
Ensure each line with a colon has the format 'key: value' with a space after colon.
Upgrade
Version history
3.8latest on PyPI · released Dec 26, 2025
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources