Generated: 2026-06-23 (America/Vancouver)
A LTspice .net file is a SPICE netlist text file consumed by the LTspice simulator. In LTspice, .net, .cir, and .sp are all accepted as simulation netlists.
Important distinction:
- LTspice simulation netlist (
.net/.cir/.sp) is for SPICE simulation. - LTspice Tools > Export Netlist creates PCB/layout exchange netlists (ExpressPCB, Allegro, etc.), not simulation decks.
- In schematic workflow (
.asc), LTspice flattens schematic hierarchy and generates a simulation netlist at run/update time. - The simulator executes that flat textual deck.
- You can also hand-author or externally generate
.net/.cir/.spand run directly.
- First line is ignored (treated as title/comment).
.ENDusually terminates the deck; it can be omitted, but anything after.ENDis ignored.- Order of statements (except local scoping constructs) is mostly declarative.
The first non-blank character determines line type.
Valid leading classes (current LTspice help, 2025 era):
*: whole-line comment+: continuation of previous line.: dot directive- Device prefixes:
A B C D E F G H I J K L M O Q R S T U V W X Z - FRA-related device prefixes:
@(FRA analyzer),&(FRA probe)
- Leading spaces/tabs are ignored.
- Keywords are case-insensitive.
- A line beginning with
+appends to the previous logical line. - The
+itself is stripped.
- Whole-line comment: first nonblank char
*. - Inline comment:
;begins comment from that point onward. - In practice, generated or hand-edited decks sometimes also use a leading
;as a whole-line comment. The localelectronics_designvalidator accepts that form.
Current LTspice help documents support for:
- UTF-16 LE (with/without BOM)
- UTF-8 (with/without BOM) — preferred
- Latin-1 fallback in specific invalid-UTF8 cases
Older LTspice docs reference ASCII/Unicode generally; modern behavior is broader and explicit.
- Scientific notation:
1e-3 - Engineering suffixes:
T G Meg K mil m u/μ n p f - Compact notation: e.g.,
6K34meaning6.34K
Unrecognized letters after a number are often ignored unless strict mode is enabled. Example pitfall:
4Faradsmay be interpreted as4f(4 femto)
Mitigation:
.options reject_number_tails(modern LTspice) to make such tails a syntax error.
- In SPICE tradition,
Mmeans milli (1e-3), not mega. - Use
Megfor mega (1e6).
- Ground node is
0(andGNDis treated specially). - Node names are strings;
0and00are different nodes. - Node names can be parameterized/dynamic in modern LTspice using expressions in braces in some contexts.
- One or more element/directive lines following the first (ignored) title line
- Exactly one simulation analysis directive per run context (see Section 9)
- Properly paired
.SUBCKT ...and.ENDS - Legal element instance syntax for each leading prefix
- Unknown first nonblank leading character (not in valid leading classes)
- Device line with wrong pin count/order for that device class
- Missing model name where required (
D,Q,J,M,S,W,O,U,Z, etc.) - Unmatched
.SUBCKT/.ENDS - Referencing undefined subcircuit on
X...invocation - Malformed parameter expression or unresolved parameter dependency cycle
- Physically impossible or out-of-range parameters (e.g., illegal coupling coefficient out of range for
K) - Values that parse but are unintended due to suffix mistakes (
1Missue) - Broken file paths/URLs in
.include/.lib
- Floating nodes, singular matrix conditions, inconsistent source loops
- Invalid transformer topology, etc. (can be checked by
topologycheckoption)
For simulation .net decks, the primary lexical keywords are these line starters:
*comment+continuation.directivesAspecial function devicesBbehavioral sourceCcapacitorDdiodeEVCVSFCCCSGVCCSHCCVSIindependent current sourceJJFETKmutual inductanceLinductorMMOSFETOlossy transmission lineQBJTRresistorSvoltage-controlled switchTlossless transmission lineUuniform RC lineVindependent voltage sourceWcurrent-controlled switchXsubcircuit instanceZMESFET/IGBT@frequency response analyzer device (new LTspice FRA flow)&frequency response probe device (new LTspice FRA flow)
Current LTspice help (2025-era online manual) lists:
.AC.BACKANNO.DC.END.ENDS.FOUR.FRA.FUNC.GLOBAL.IC.INCLUDE.KEEPNODE.LIB.LOADBIAS.LOADSTATE.MACHINE.MEASURE.MODEL.NET.NODESET.NOISE.OP.OPTIONS.PARAM.SAVE.SAVEBIAS.SAVESTATE.STEP.SUBCKT.TEMP.TF.TRAN.WAVE
Legacy LTspice XVII help also documented directives like .TEXT and .FERRET; these are not listed in the modern official command index.
Modern LTspice help states there are seven primary analysis modes:
.AC.DC.NOISE.OP.TF.TRAN.FRA
Typical rule: for a given run, specify one analysis mode command.
.tran <Tstep> <Tstop> [Tstart [dTmax]] [modifiers].ac <oct|dec|lin> <Nsteps> <StartFreq> <EndFreq>.ac list <f1> [f2 ...].ac file=<filename>.dc <sweep1> [<sweep2> [<sweep3>]].noise V(<out>[,<ref>]) <src> <oct|dec|lin> <Nsteps> <StartFreq> <EndFreq>.noise ... list .../.noise ... file=....tf V(<node>[,<ref>]) <source>or.tf I(<vsource>) <source>.op.fra [Tstart=...] [dTmax=...] [Tstep=...] [Tstop=...] [uic] [startup].net [V(out[,ref])|I(Rout)] <Vin|Iin> [Rin=<val>] [Rout=<val>].subckt <name> <pins...> [params...].ends [name].param <name>=<expr> ....func <name>(args) {expr}(modern LTspice also relaxes braces in many contexts).model <modname> <type>(<params...>).step ...supports linear/log stepping,list, andfile=forms.save ...supports wildcard patterns.lib <filename>and.lib <filename> <entryname>sectional form.include <filename>.options <k=v ...>and flag options.ic [V(node)=...] [I(Lx)=...].nodeset V(node)=...
uicsteadynodiscardstartupstep
Rxxx n1 n2 <value> [tc=...] [temp=...]Cxxx n1 n2 <cap> [ic=...] [Rser=...] [Lser=...] [Rpar=...] [Cpar=...] [m=...] [RLshunt=...] [temp=...]Lxxx n+ n- <L> [ic=...] [Rser=...] [Rpar=...] [Cpar=...] [m=...] [temp=...]Kxxx L1 L2 [L3 ...] <coupling_coeff>Txxx L+ L- R+ R- Zo=<value> Td=<value>Oxxx L+ L- R+ R- <LTRA_model>Uxxx N1 N2 Ncom <URC_model> L=<len> [N=<lumps>]
Vxxx n+ n- <dc_or_waveform> [AC=...] [Rser=...] [Cpar=...]Ixxx n+ n- <dc_or_waveform> [AC=...] [load]
Waveform keywords commonly valid in source value field:
PULSE(...)SINE(...)EXP(...)SFFM(...)PWL(...)wavefile=<filename> [chan=<n>]- Additional source forms include tables and step-load forms for current sources in LTspice docs.
Exxx ...VCVS (gain / table / Laplace / value expression / POLY)Fxxx ...CCCS (gain / expression / POLY)Gxxx ...VCCS (gain / table / Laplace / value expression / POLY)Hxxx ...CCVS (gain / expression / POLY)Bxxx ...arbitrary behavioral source (V=orI=with expression, Laplace options)
Dxxx anode cathode <model> ...Qxxx C B E [S] <model> ...Jxxx D G S <model> ...Mxxx D G S B <model> ...(and VDMOS form)Sxxx ... <SW_model> ...Wxxx ... <CSW_model> ...Zxxx ... <NMF/PMF/NIGBT/PIGBT-context model> ...
Xxxx nodes... <subckt_name> [param=expr ...]Axxx ... <model> [params...]special-function devices (partly undocumented and version-sensitive)
@xxx ...FRA analyzer device&xxx ...FRA probe device
Core model type keywords include:
SW,CSW,URC,LTRA,D,NPN,PNP,NJF,PJF,NMOS,PMOS,NMF,PMF,NIGBT,PIGBT,VDMOS
Model parameter sets are type-specific and extensive.
Used in .param, behavioral sources, and expression-valued parameters.
Highlights:
- Constants (e.g.,
PI,BOLTZ, etc.; some defaults are redefinable) - Functions: arithmetic, trig, random, table lookup, selection, logic helpers
- Boolean/logical operators and arithmetic operators
- String support in modern LTspice
.param(not only numeric), includingselect(...)patterns for model/subckt name parameterization
Version note:
- Modern LTspice (24.1+) relaxes mandatory braces/apostrophes for many substitutions, except where omission becomes ambiguous.
Valid:
- Relative or absolute file paths
- Quoted paths when spaces exist
.libsectional form:.lib "file" <entryname>with.lib <entryname> ... .endlin library
Risky/invalid patterns:
- Missing extension when file actually requires one
- Wrong search path assumptions
- Broken URL includes/libraries (if using URL forms)
Conversion portability note:
- A
.libreference identifies the simulation library; it does not necessarily identify the.asysymbol used to draw anX...instance. - A subcircuit name and its symbol filename may differ. For example,
level2can be defined insideUniversalOpAmp2.libwhile the matching symbol isUniversalOpAmp2.asy. - If a netlist will be converted back to an
.asc, preserve LTspice'sModelFilecomment hint or provide an equivalent symbol mapping through the conversion settings. Do not assume that the.subcktname is an.asybasename.
.subckt/.endsdefines local scope..paramand.funccan be scoped within subcircuits.- LTspice expands hierarchy to flat netlist before simulation.
- Subcircuit instances get unique expanded instance names.
- Ensure one valid analysis directive (
.tran/.ac/.dc/.noise/.op/.tf/.fra). - Ensure all model-requiring instances reference an existing
.modelor included model. - Ensure all
X...calls map to defined.subcktnames. - Ensure no unknown line-leading characters.
- Ensure continuation lines begin with
+in column after optional whitespace. - Validate numeric suffixes (
MegvsM, tail text). - Use
.options reject_number_tailsfor strict numeric parsing. - Verify ground/reference node strategy (
0/GND) and avoid floating islands. - Validate file paths for
.include/.lib/.wavefile. - If using modern-only features (
@,&,.fra, relaxed substitution), verify target LTspice version.
The Python package in this repository intentionally implements a stricter project-level validation profile than raw LTspice parsing in a few places. This is deliberate so the API can catch formatting mistakes early and return stable error messages.
This validator checks:
- file exists
- file is readable
- each nonblank line starts with a valid LTspice line class
- continuation lines only appear after a prior logical line
- dot directives must have a whitespace boundary after the directive name
- device lines must have at least the minimum positional token count for their prefix
- project-specific spacing mistakes such as
R1Vcc ...,V1Vcc ...,.stepPARAM ..., and.libC:\...are rejected
Important implementation nuance:
- For this project,
Qlines are treated strictly as needing collector, base, emitter, substrate, and model tokens in order to catch merged-node spacing mistakes such asQ1 N001N002 0 0 2N3904. VandIlines allow the source value to be omitted because LTspice sample decks can use those sources as sweep variables, e.g.V1 N001 0.
Public API return contract:
False, "File not found!"False, "No permission to read file!"False, "Line format/spacing is invalid! Line <n>"True, ""
This validator is not a generic LTspice theorem prover. It enforces the footer convention used in this repository and test suite.
It requires:
- the file must already pass the format validator
- at least one simulation analysis directive somewhere in the deck
- final nonblank line must be
.end - penultimate nonblank line must be
.backanno
So, a syntactically parseable LTspice deck can still fail this validator if it omits an analysis command or does not end with the repository-style footer.
Public API return contract:
False, "File not found!"False, "No permission to read file!"False, "Footer information is invalid! Line <n>"True, ""
This validator performs a lightweight structural connectivity check, not a full simulator topology solve.
It counts element-port references and requires each non-exempt node to appear on at least two device ports.
Nodes treated as exempt:
0GND- names beginning with
NC,NC_, orNC-
Important limitations:
- This is a graph-style connection count, not a full singular-matrix or operating-point analysis.
Kmutual inductance statements do not contribute nodes because they reference inductors, not electrical nets.- Subcircuit
X...lines contribute all positional tokens before the subcircuit name and before anyparam=valuetokens.
Public API return contract:
False, "File not found!"False, "No permission to read file!"False, "Node is not connected correctly! Line <n>"True, ""
ltspice_netlist_to_asc() uses the public symbol-initial, autoplace, and wiring stages. The netlist must therefore carry enough information to resolve every device to an available .asy file.
For ordinary primitives, the mapping is usually direct:
R1 in out 1k ; res.asy
C1 out 0 100n ; cap.asy
For X... subcircuits, keep the simulation subcircuit name unchanged and preserve the LTspice-generated ModelFile hint when the symbol filename differs:
XU1 in out VCC VEE out level2 Avol=1Meg
* Library below included based on ModelFile attribute of instance XU1 (C:\users\user\AppData\Local\LTspice\lib\sym\OpAmps\UniversalOpAmp2.asy)
.lib C:\users\user\AppData\Local\LTspice\lib\sub\UniversalOpAmp2.lib
The comment is metadata for schematic reconstruction; it does not alter SPICE simulation. The converter extracts the .asy basename from the hint and searches the configured custom_search_paths, Wine path, and Windows path. The path in the hint may remain Windows-style, but the actual symbol must exist in one of the configured search roots.
Before conversion, check:
- Every
X...instance has either a matching.asybasename or aModelFilehint. - The hinted
.asyfile exists in a configured search root. - The
.libfile contains the referenced.subcktname and remains available for simulation. - Run
ltspice_netlist_to_symbol_initial()first and inspect that eachSYMBOLvalue names the intended.asyfile before invoking autoplace.
If symbol geometry cannot be resolved, the current autoplace API reports the generic AUTOPLACE_FAILED; inspect the generated symbol-initial JSON to distinguish a missing file from a placement or routing failure.
VALID V2 voltage of 12V DC from Vcc to ground 0
V2 Vcc 0 12
VALID V1 voltage with a 4V DC and 2V AC from Node IN to ground 0
V1 IN 0 4 AC 2
INVALID, Missing DC voltages
V1 IN 0 AC 1
* RC step
V1 in 0 PULSE(0 1 0 1n 1n 1u 2u)
R1 in out 1k
C1 out 0 100n
.tran 0 10u
.end
Y1 a b 1k
Y is not a valid standard LTspice device prefix.
R1 a b 1M
Parses as 1 milliohm in SPICE semantics, not 1 megaohm.
X1 a b c MissingSubckt
.tran 1m
.end
Fails if MissingSubckt is never defined/included.
C1 a b 4Farads
May parse to 4f unexpectedly unless strict number-tail rejection is enabled.
- LTspice XVII-era docs and LTspice 24/26 docs are not identical.
- Newer docs add FRA flow (
.fra,@,&), state save/load directives, modern parser details. - Some older-documented directives (e.g.,
.text,.ferret) are absent from current official dot-command index. - String/quote handling and parameter substitution behavior changed in newer versions (notably 24.1+).
- Repository tooling may be stricter than LTspice itself; treat this document's Section 17.1 as the authoritative description of the local Python API behavior.
For simulation .net, “all possible keywords” is best interpreted in layers:
- Lexical line starters (
* + . A..Z @ &) — finite and listed above. - Dot directives (current full list above).
- Device-instance parameter keywords (very large, device-specific, version-evolving).
- Model-parameter keywords (
.modeltype dependent; extremely large). - Expression language functions/operators and reserved names.
So: the format is not a single tiny grammar; it is a compact top-level grammar plus many device/model subgrammars.
Primary references used:
- LTspice Help (current online manual), General Structure and Conventions
- LTspice Help, Dot Commands (current list)
- LTspice Help, Circuit Elements (current quick syntax + flags/dynamic nodes)
- LTspice Help,
.AC
- LTspice Help,
.DC
- LTspice Help,
.NOISE
- LTspice Help,
.TF
- LTspice Help,
.TRANand modifiers
- https://ltspicehelpmanual.azurewebsites.net/TRAN--DoaNonlinearTransientAnaly.htm
- https://ltspicehelpmanual.azurewebsites.net/transientanalysisoptions.htm
- LTspice Help,
.NET
- LTspice Help,
.PARAM
- LTspice Help,
.OPTIONS
- LTspice Help,
.LIB
- LTspice Help,
.SAVE
- LTspice Help,
.STEP
- LTspice Help,
.FRAand FRA devices@/&
- https://ltspicehelpmanual.azurewebsites.net/dotfra.html
- https://ltspicehelpmanual.azurewebsites.net/fra_device.html
- https://ltspicehelpmanual.azurewebsites.net/fra_probe.html
- LTspice Help, SPICE Netlist / PCB Netlist Extraction
- https://ltspicehelpmanual.azurewebsites.net/spicenetlist.htm
- https://ltspicehelpmanual.azurewebsites.net/pcbnetlistextraction.htm
- LTspice EngineerZone clarification (LTspice 26 netlist syntax and export-netlist confusion)
- LTspice XVII legacy help mirror (cross-check of historical syntax and directives)
- https://ltwiki.org/files/LTspiceHelp.chm/html/GeneralConventions.htm
- https://ltwiki.org/files/LTspiceHelp.chm/html/DotCommands.htm
- https://ltwiki.org/files/LTspiceHelp.chm/html/CircuitElementQuickReference.htm
- https://ltwiki.org/files/LTspiceHelp.chm/html/DotModel.htm
- https://ltwiki.org/files/LTspiceHelp.chm/html/V-device.htm
- https://ltwiki.org/files/LTspiceHelp.chm/html/I-device.htm
- https://ltwiki.org/files/LTspiceHelp.chm/html/ExternalNetlists.htm