netlistmod
netlistmod is a source-preserving SPICE netlist editing library. Its goal is
to make permitted value and directive edits while preserving the original text
and circuit topology.
Supported dialects
The caller always selects the dialect; there is no default and no detection.
| Dialect | Dialect |
Input | Elements | Reference | Validated on |
|---|---|---|---|---|---|
| ngspice | NGSPICE |
.cir, .sp, .net, KiCad exports |
R, C, L, K, V, I, D, X; Q, M, J, Z (M13); E, F, G, H, S, W (M14); B and the expression forms (M15) | ngspice manual | ngspice 47 |
| LTspice | LTSPICE |
.net, .cir (an .asc schematic is exported first) |
R, C, L, K, V, I, D, X; Q, M, J, Z (M13); E, F, G, H, S, W (M14); B and the expression forms (M15) | ltspice-reference | LTspice 26.1.1, Windows |
Where a solver and the library differ, the file is docs/grammars/<dialect>/discrepancies.md. Other
device letters raise UnsupportedConstruct until their phase 2 milestone.
Quick start
pip install netlistmod
To work on the library itself, clone it and run uv sync.
>>> from pathlib import Path
>>> from tempfile import TemporaryDirectory
>>> from netlistmod import Dialect, Netlist
>>> folder = TemporaryDirectory()
>>> path = Path(folder.name) / "divider.cir"
>>> _ = path.write_bytes(b"divider\nV1 in 0 DC 3\nR1 in out 1k ; top\nR2 out 0 1k\n.op\n.end\n")
>>> netlist = Netlist.load(path, dialect=Dialect.NGSPICE)
>>> edited = netlist.set_value("R2", "3k").directives.set(".tran 1u 5u")
>>> edited.save()
>>> print(path.read_text(), end="")
divider
V1 in 0 DC 3
R1 in out 1k ; top
R2 out 0 3k
.op
.tran 1u 5u
.end
>>> folder.cleanup()
Every edit returns a new netlist that has been re-parsed and checked against the topology of the original. save() changes only the edited text: comments, spacing, line endings and encoding stay as they were. For the whole cycle with a solver, see edit_and_simulate.py.
What it does and does not do
- Reads titles, comments, the phase 1 elements,
.param,.model,.subckt, the analysis, option and output directives, and LTspice's.step, into typed nodes with exact source spans. It answers queries about lines, references, nets and connections. - Edits values, formulas, instance and model parameters, source DC and AC values and functions,
.paramlines and directives, and adds an.include. - Preserves other dot-commands verbatim.
.control,.if,.includeand.libare opaque: their contents are not read. - Never changes topology (elements, nodes, subcircuit ports), evaluates a value, or launches a solver.
- Refuses loudly. A line outside the grammar is an error, not a guess. Netlists with Q or M devices are rejected until phase 2.
Status
Phase 1 is complete, with both dialects validated on their solvers (M9), and phase 2 is under way. The current release is an alpha (0.5.0): the public API may still change before 1.0.
Supported platforms are Linux and Windows, with Python 3.13 or newer. LTspice validation runs on Windows. macOS is not tested.
- Guides: usage, including the error reference.
- Design: architecture, phase 2 plan, phase 1 plan.
- Development: testing, changelog.
Metadata
Release files for netlistmod 0.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| netlistmod-0.5.0.tar.gz | 113.8 kB | With provenance | Details for netlistmod-0.5.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| netlistmod-0.5.0-py3-none-any.whl | Python 3 | none | any | Details for netlistmod-0.5.0-py3-none-any.whl |
Total release size: 250.0 kB
Release files / netlistmod-0.5.0.tar.gz
| Download URL | netlistmod-0.5.0.tar.gz |
|---|---|
| Size | 113.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b624ab05e49fbca28adcf7eacd832b51e334565c5efd5f6a3699c1ad6939ce95
|
|
BLAKE2b-256 checksum How to use checksums |
e228adf83751c819b8071b82ed22e5165f4d227def1870579b85cdf926060f3f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 7, 2026.
Transparency logRelease files / netlistmod-0.5.0-py3-none-any.whl
| Download URL | netlistmod-0.5.0-py3-none-any.whl |
|---|---|
| Size | 136.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
72293ae2d9932874665d8988f2735c949501fb970d7c0bac1bdc4ad38efdcee3
|
|
BLAKE2b-256 checksum How to use checksums |
caeb36493963a95586d0931c2564930cb0d7d4611dc4d38c9a0d52f6df9dfe8c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 7, 2026.
Transparency logSecurity for netlistmod 0.5.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for netlistmod-0.5.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 7, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.