Importing SPICE netlists
On this page
Development builds can convert a deliberately bounded Ngspice-compatible netlist into editable Kessetsu source:
kess import filter.cir --output filter.kess
kess check filter.kess
kess simulate filter.kess
If --output is omitted for a file input, the CLI uses the same basename with .kess.
Existing files require --force. Standard input is supported with
kess import - --output circuit.kess; it never chooses an implicit file destination.
In development Web Hub builds, choose File > Import SPICE netlist... or drop a supported netlist onto the editor. Conversion runs locally through the same Core contract. A complete import opens as an unsaved editable circuit; a rejected import leaves the current document intact.
What the first subset accepts
| SPICE form | Kessetsu result |
|---|---|
R, C, L with literal values |
resistor, capacitor, inductor |
Independent V and I |
DC, AC, three-field SINE, seven-field PULSE or PWL source |
D |
selected built-in 1N4148/1N4007 models |
Q |
selected typed built-in NPN/PNP models |
Three-terminal M, or four-terminal with bulk tied to source |
selected built-in MOSFET models |
.op, bounded .tran, .ac, single-source .dc |
typed simulate statements |
.param NAME=literal |
typed editable parameter, with unit inferred from its supported uses |
Source-embedded .SUBCKT plus root X instances |
editable module/use, preserving ports, local topology and literal typed overrides |
Continuation lines beginning with +, comments, .title and .end are understood. SPICE node
0 becomes the explicit GND net. Other node and component names are preserved when valid or
mapped deterministically when Kessetsu identifiers require it. --format json returns the
kessetsu.spice-import.v1 report, source hash, name mappings, diagnostics, summary and verified
editable source.
SPICE suffix meaning is preserved rather than copied blindly. In SPICE, 10M means 10 milliohms,
while Kessetsu uses SI casing where 10M would mean 10 megaohms. The importer therefore writes a
normalized number and canonical recompilation confirms the resolved value.
Fail-closed limits
The initial importer rejects these constructs instead of guessing or silently removing them:
.control/.endc, shell-like or simulator-control content;- arbitrary
.include/.libpaths; - inline
.modeland general SPICE expressions; - parameter expressions, unused parameters or one parameter used across conflicting electrical units;
- controlled or behavioral sources and unsupported component families;
- unknown semiconductor models, untied MOSFET bulk nodes, non-zero AC source phase, or analysis options that the typed Kessetsu IR cannot represent.
Embedded subcircuits are intentionally structural, not raw simulator text. A .SUBCKT must have
explicit interface nodes and may contain the same supported component subset as the root circuit.
Literal defaults declared after PARAMS: and named literal/root-parameter overrides on a root X
instance remain typed module parameters. Nested X instances, body directives, implicit global
node 0, positional parameters and expression-valued defaults/overrides are rejected rather than
flattened or guessed. Expose ground as an ordinary subcircuit port and pass root node 0 to it.
An external .include/.lib is different from an embedded topology: its bytes, entry pins,
provenance, license and redistribution policy cannot be inferred safely from a path. Import
therefore rejects it. Bind such a dependency through Kessetsu's hash-pinned typed external model
contract; the importer never opens an arbitrary path or silently substitutes a generic device.
An error includes the original source line and no .kess file is written. This is intentionally
narrower than the complete SPICE language. Support expands only when connectivity, values, models
and analysis meaning can be represented and verified without a raw-SPICE bypass.
PySpice
Generate a netlist in the user's own Python environment, save it, then import that file with the same command. Kessetsu does not execute Python and does not claim to preserve Python loops, functions or intent that are absent from the generated netlist.
For example, this PySpice 1.5 circuit emits only constructs in the supported import subset:
from PySpice.Spice.Netlist import Circuit
from PySpice.Unit import u_V, u_kOhm
circuit = Circuit("Voltage divider")
circuit.V("IN", "IN", circuit.gnd, 10 @ u_V)
circuit.R(1, "IN", "OUT", 1 @ u_kOhm)
circuit.R(2, "OUT", circuit.gnd, 1 @ u_kOhm)
circuit.raw_spice += ".op\n"
with open("divider.cir", "w", encoding="utf-8") as output:
output.write(str(circuit))
Then run kess import divider.cir --output divider.kess. Compatibility is determined by the
generated SPICE text, not by the Python library version: unsupported devices or directives still
fail closed with a source-line diagnostic.
The successful .kess file is the normal save, share, edit, simulation and export artifact. Keep
the original netlist beside it when provenance matters; its exact SHA-256 identity appears in the
generated source header and JSON report. Imported simulation remains model-based evidence, not a
guarantee of physical hardware behavior.