Skip to main content

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, E, F, G, H, S, W, B, T, O, U (URC), Y, P, A (code models) and N (OSDI), with the expression, TABLE, POLY, FREQ and gate forms 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, E, F, G, H, S, W, B, T, O, U, A (special functions), @ and &, with the expression, table=, POLY and Laplace= forms ltspice-reference LTspice 26.1.1, Windows

Where a solver and the library differ, the file is docs/grammars/<dialect>/discrepancies.md. Every device letter is supported. Two constructs are out of scope for v1 and raise UnsupportedConstruct: the ngspice digital U (a U line that is not a URC line), whose libraries need PSpice compatibility mode, and LTspice's .machine (decision 0020).

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, every device letter of both dialects, .param, .model, .subckt, .global, 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 and behavioural expressions (set_value, set_formula, set_expression, remove_value); instance and model parameters (set_param, set_instance_param, set_model_param, remove_param, remove_model_param); an element's model (set_model); a source's DC and AC values and its function (set_dc, set_ac, set_stimulus, set_stimulus_arg, remove_stimulus); a coupling (set_coupling), a table (set_table), POLY coefficients (set_poly_coefficients) and a switch's state (set_switch_state); .param lines (params) and directives (directives); and adds an .include (add_include).
  • Preserves other ngspice dot-commands verbatim. On ngspice, .control, .if, .include and .lib are opaque: their contents are not read. On LTspice, .include and .lib are opaque, and the dot-commands are a closed list: any other, .control and .if among them, is a ParseError.
  • 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. A construct outside v1 (the ngspice digital U, LTspice .machine) raises UnsupportedConstruct.

Status

The library is feature complete for v1: every device letter of both dialects is supported, and both dialects are validated on their solvers. The current release is the 0.9.0 beta: the public API may still change before 1.0, which is decided after practical use.

Supported platforms are Linux and Windows, with Python 3.13 or newer. LTspice validation runs on Windows. macOS is not tested.

Metadata

Release files for netlistmod 0.9.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for netlistmod 0.9.0
File Size Uploaded Provenance Actions
netlistmod-0.9.0.tar.gz 146.4 kB With provenance Details for netlistmod-0.9.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for netlistmod 0.9.0
File Interpreter ABI Platform Actions
netlistmod-0.9.0-py3-none-any.whl Python 3 none any Details for netlistmod-0.9.0-py3-none-any.whl

Total release size: 327.4 kB

Release files / netlistmod-0.9.0.tar.gz

Download URL netlistmod-0.9.0.tar.gz
Size 146.4 kB
Tags Source
SHA-256 checksum
How to use checksums
b1b77ab76e381b875f3f3be8e0bcd4afd514c575a8dc1744e07a9344b7ada025
BLAKE2b-256 checksum
How to use checksums
655d852c92986420169a4a550211fb311db2765c55dbfabf83368ecd154f0b5e
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 12, 2026.

Transparency log

Release files / netlistmod-0.9.0-py3-none-any.whl

Download URL netlistmod-0.9.0-py3-none-any.whl
Size 181.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
16323b8870a25083b10034b69ec95e3cb1cac881ae028c9f6aa86a02736d556e
BLAKE2b-256 checksum
How to use checksums
dca69256ea3fc012f4bd3389d775e122745f54b5e09fdbee6e60edfc22d46c5e
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 12, 2026.

Transparency log

Security for netlistmod 0.9.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.

Select from 2 files

Attestation for netlistmod-0.9.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 12, 2026.

Transparency log

A 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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page