Schematex

Circuit schematic

About circuit schematics

A circuit schematic is the standard graphical representation of an electronic circuit — components drawn as standardized symbols, connected by wires, with enough information to build or simulate the circuit. Electronics engineers use them throughout the product lifecycle: from initial concept to PCB layout review and datasheet documentation. Schematex follows IEEE Std 315-1975 / ANSI Y32.2 and IEC 60617 for component symbols.

The DSL has two modes. Netlist mode (recommended) is SPICE-style: you list components and the nodes they connect to, and the engine lays everything out automatically — each line is self-contained, with no spatial state to track. Positional mode is for hand-drawing: components chain in a direction like Schemdraw. Both produce the same SVG. For generated diagrams (e.g. by an LLM), always use netlist mode — it has by far the smaller error surface.

circuit·§ IEEE 315
↘ preview
100%
CE Amp (netlist) Circuit schematic with 6 components CE Amp (netlist) +V19VRc2.2kRb100kQ1Re1k
UTF-8 · LF · 6 lines · 97 chars✓ parsed·4.5 ms·5.0 KB SVG

The smallest useful circuit: a voltage source, a resistor, and a capacitor to ground — an RC low-pass filter.

circuit·§ IEEE 315
↘ preview
100%
RC Low-Pass Circuit schematic with 4 components RC Low-Pass +V15VR11kC1100n
UTF-8 · LF · 4 lines · 67 chars✓ parsed·0.8 ms·3.9 KB SVG

Three rules cover ~90% of netlist usage:

  1. Start with circuit "Title" netlist (the netlist keyword switches on this mode).
  2. Each line is componentId nodeA nodeB value — one component, the two (or more) named nodes it connects to, then its value.
  3. Two components that share a node name are wired together. 0, gnd, or GND is the ground net (a ground symbol is drawn automatically).

The component-id prefix sets the symbol: R*→resistor, C*→capacitor, L*→inductor, V*→voltage source, D*→diode, Q*→BJT. When the prefix is ambiguous, add type= (e.g. X1 a b type=opamp). You never compute coordinates — the engine derives placement from the connectivity.

Comments must start with # on their own line.


2. Components

2.1 Netlist mode syntax

A netlist line has the form:

componentId node... [value] [type=…] [label="…"]

The positional nodes come first; a trailing token that doesn't look like a node becomes the value. Example — a transistor (4 nodes) and a resistor:

Q1 c b e npn        # collector, base, emitter nodes + model
Rc vcc c 2.2k       # two nodes + value

Optional orientation hint. The engine auto-orients symbols by role (sources up, ground down, the rest horizontal). To nudge a single symbol, add dir=right|left|up|down — connectivity is unchanged, only the symbol's facing rotates:

C1 out 0 100n dir=down    # draw C1 as a shunt cap hanging to ground

This is the lightweight layout-control layer (like Lcapy's per-component orientation): netlist connectivity does the heavy lifting, dir= only refines appearance. For full geometric control, use positional mode below.

2.2 Positional mode syntax (hand-drawing)

Positional mode is for manually laying out a schematic geometrically. Prefer netlist mode for generated output — positional mode requires tracking a moving "cursor" across lines, which is error-prone for LLMs.

A named component line has the form:

id: type direction [value="…"] [label="…"]

An anonymous component omits the id: prefix — the parser assigns an auto ID.

R1: resistor right value="4.7k" label="R1"
capacitor down value="100n"

Direction is one of right (default), left, up, down. It controls which way the component extends from the current cursor position.

2.3 Passive components

DSL typeDescription
resistorZigzag (ANSI) or rectangle (IEC)
potentiometerResistor + wiper arrow, 3-pin
rheostat2-pin variable resistor
thermistor_ntcNTC thermistor (also: therm, ntc)
thermistor_ptcPTC thermistor (also: ptc)
ldrLight-dependent resistor
varistorVoltage-dependent resistor
fuseStandard fuse
fuse_slowSlow-blow fuse (T designation)
capacitorNon-polar capacitor
electrolytic_capPolar/electrolytic capacitor (also: ecap)
variable_capVariable capacitor
inductorAir-core inductor
inductor_ironIron-core inductor
inductor_ferriteFerrite-core inductor
variable_inductorVariable inductor
ferrite_beadEMI ferrite bead
crystalQuartz crystal oscillator (also: xtal)
transformerCoupled coils (also: xfmr)
circuit·§ IEEE 315
↘ preview
100%
Passive components gallery Circuit schematic with 11 components Passive components gallery 1k100n10u
UTF-8 · LF · 15 lines · 335 chars✓ parsed·3.2 ms·3.8 KB SVG

2.4 Sources and power

DSL typeDescription
voltage_sourceCircle + polarity (also: vsource)
current_sourceCircle + arrow (also: isource)
ac_sourceCircle + sine symbol (also: acsource)
batteryAlternating long/short terminal lines
vccPower rail arrow (pointing up)
groundEarth ground — 3 decreasing lines (also: gnd)
gnd_signalSignal ground — solid triangle
gnd_chassisChassis ground
gnd_digitalDigital ground
circuit·§ IEEE 315
↘ preview
100%
Sources and power gallery Circuit schematic with 18 components Sources and power gallery +5V9V120V
UTF-8 · LF · 26 lines · 381 chars✓ parsed·1.3 ms·5.1 KB SVG

2.5 Semiconductors — diodes

DSL typeDescription
diodeTriangle + cathode bar
zenerDiode + bent cathode bar
schottkyDiode + S-bar
ledDiode + outward emission arrows
photodiodeDiode + inward light arrows
varactorDiode + variable capacitor
tvs_diodeBidirectional TVS (two bent bars)
bridge_rectifier4-diode bridge, 4-pin
circuit·§ IEEE 315
↘ preview
100%
Diode types gallery Circuit schematic with 13 components Diode types gallery
UTF-8 · LF · 15 lines · 207 chars✓ parsed·0.5 ms·4.6 KB SVG

2.6 Semiconductors — transistors

DSL typeDescription
npnNPN BJT (also: transistor, bjt_npn)
pnpPNP BJT (also: bjt_pnp)
darlington_npnNPN Darlington pair
darlington_pnpPNP Darlington pair
nmosN-channel MOSFET enhancement (also: mosfet_n)
pmosP-channel MOSFET enhancement (also: mosfet_p)
nmos_depletionN-channel MOSFET depletion
jfet_nN-channel JFET
jfet_pP-channel JFET
igbtIGBT
scrSCR / thyristor
triacTRIAC
diacDIAC
phototransistorNPN with light arrows
optocouplerLED + phototransistor in isolation box
circuit·§ IEEE 315
↘ preview
100%
Transistor types gallery Circuit schematic with 10 components Transistor types gallery
UTF-8 · LF · 15 lines · 216 chars✓ parsed·0.5 ms·4.6 KB SVG

2.7 Analog ICs and op-amps

DSL typeDescription
opampTriangle: +/− inputs, output
comparatorSame shape, open-collector output
schmitt_bufferBuffer + hysteresis symbol
tri_state_bufferBuffer + enable pin
instrumentation_ampThree-op-amp INA block
generic_icConfigurable rect with labeled pins (also: ic)
voltage_regulator3-terminal block: IN/GND/OUT (also: reg)
dc_dc_converter2-port block with DC/DC label
555_timer8-pin 555 pinout block (also: timer555)
circuit·§ IEEE 315
↘ preview
100%
Analog IC gallery Circuit schematic with 10 components Analog IC gallery ++IC12348765
UTF-8 · LF · 14 lines · 227 chars✓ parsed·0.5 ms·3.8 KB SVG

2.8 Switches and relays

DSL typeDescription
switch_spstSingle-pole single-throw
switch_spdtSingle-pole double-throw
switch_dpdtDouble-pole double-throw
push_noPush button normally-open
push_ncPush button normally-closed
relay_coilRelay coil (2-pin rect)
relay_noRelay contact normally-open
relay_ncRelay contact normally-closed
circuit·§ IEEE 315
↘ preview
100%
Switch and relay gallery Circuit schematic with 12 components Switch and relay gallery
UTF-8 · LF · 17 lines · 297 chars✓ parsed·0.5 ms·4.2 KB SVG

2.9 Electromechanical and measurement

DSL typeDescription
motorCircle + M
speakerCone + box
microphoneCapsule symbol
buzzerPiezo buzzer
ammeterCircle + A
voltmeterCircle + V
wattmeterCircle + W
oscilloscopeCircle + waveform

2.10 Connectors and annotations

DSL typeDescription
wirePlain wire segment
dotJunction dot (T-junction marker)
labelNet label / flag
portNamed port (hollow circle)
test_pointTP marker
no_connectX — intentionally unconnected pin
antennaAntenna stub
circuit·§ IEEE 315
↘ preview
100%
Passive components Circuit schematic with 7 components Passive components R11kC1100n9V
UTF-8 · LF · 9 lines · 183 chars✓ parsed·0.5 ms·3.4 KB SVG

3. Wiring and branching

3.1 Wire segments

wire direction [N] draws a bare wire from the current cursor in the given direction. An optional number sets the length in pixels.

wire right
wire down 40
wire left 20

3.2 Jumping the cursor with at:

at: id.end moves the cursor to a named anchor without drawing anything. Use it to branch from a previously placed component.

R1: resistor right value="10k"
at: R1.end
C1: capacitor down value="100n"

Named anchor suffixes: end, start. Components retain their ID across the whole diagram, so you can jump back to any previously placed component.

3.3 Junction dots

Place a dot (or use net NAME: dot) to mark a T-junction — a point where three or more wires meet. Without a dot, crossed wires are drawn as a crossover (no connection).

R1: resistor right
dot
wire right           # continues from R1.end
at: R1.end
C1: capacitor down   # branches down from the same point

3.4 Named nets

net NAME declares a named net. net NAME: dot declares the net and places a junction dot at the current cursor, remembering that location. Later, at: NAME jumps back to that net's anchor.

net VOUT: dot
R2: resistor right value="10k"
at: VOUT
C1: capacitor down value="470n"

3.5 Net labels

label "text" direction? places a text label at the current cursor position. Labels do not advance the cursor. They are useful for naming power rails or inter-sheet connections.

label "VCC" up
label "GND" down
circuit·§ IEEE 315
↘ preview
100%
RC filter Circuit schematic with 9 components RC filter +5VR11kVoutC1100n
UTF-8 · LF · 11 lines · 217 chars✓ parsed·0.5 ms·3.4 KB SVG

4. Netlist mode

Add netlist after the title on the header line to switch to SPICE-style netlist parsing. The auto-layout engine computes component positions from the net connectivity.

circuit "Low-pass filter" netlist

4.1 Netlist line format

Each line is: ID net1 net2 [net3…] [value] [key=value…]

  • ID — component identifier. The first letter determines the default type (SPICE prefix convention).
  • net1, net2, … — net names the pins connect to. Net names matching 0, gnd, ground, earth, pe, agnd, dgnd, gnda, gndd, vss, or com (case-insensitive, with optional _<word> or numeric suffix — e.g. gnd_ref, AGND_DIG, EARTH1) all canonicalize to the ground net.
  • value (optional bare token) — component value or model name.
  • key=value (optional) — label=, value=, type= overrides.

4.2 SPICE prefix → component type

PrefixDefault typePin order
Rresistorp1, p2
Ccapacitorp1, p2
Linductorp1, p2
Ddiodeanode (start), cathode (end)
Vvoltage_sourceplus, minus
Icurrent_sourceplus, minus
Qnpnc, b, e
Mnmosd, g, s
Jjfet_nd, g, s
Sswitch_spstp1, p2
Ffusep1, p2
Bbatteryplus, minus
Krelay_coilp1, p2
U, Xgeneric_iccustom via pins=
Wwirestart, end
Tterminal_blockcustom via pins= (also type=junction_box)

Scope: schematex circuit covers electrical schematics only (IEEE 315 / IEC 60617). Hydraulic and pneumatic schematics (ISO 1219) use a fundamentally different visual grammar — directional valve envelopes, cylinder symbols, line styles for pressure/return/drain — and are not supported by this engine. Hydraulic prefixes such as EV* (electrovalve), BOMBA* (pump), TANK*, DIPOSIT* will be rejected with a "cannot infer type" error.

4.3 Transistor model override

For Q lines, a trailing model name overrides the type:

Q1 c b e npn      # NPN BJT
Q2 c b e pnp      # PNP BJT
M1 d g s nmos     # N-channel MOSFET
M2 d g s pmos     # P-channel MOSFET

For D lines, similarly:

D1 anode cathode zener
D2 anode cathode led
D3 anode cathode schottky
D4 anode cathode photodiode

4.4 Netlist example

circuit·§ IEEE 315
↘ preview
100%
CE Amp (netlist) Circuit schematic with 6 components CE Amp (netlist) +V19VRc2.2kRb100kQ1Re1k
UTF-8 · LF · 6 lines · 97 chars✓ parsed·0.6 ms·5.0 KB SVG

5. Attributes

Both positional and netlist modes accept these key=value attributes:

AttributeAccepted byEffect
label="…"all componentsDisplay label (reference designator)
value="…"all componentsValue annotation (1kΩ, 100nF, 5V)
at=id.endpositional componentsStart this component at a named anchor
length=Nwire, some passivesLength in pixels

In positional mode, at= inside the component line is equivalent to a preceding at: line:

C1: capacitor down at=R1.end value="100n"

6. Labels & comments

  • Diagram title: circuit "RC Filter" — first line only.
  • Component label: label="R1" attribute — reference designator shown beside the symbol.
  • Value annotation: value="4.7k" — shown beside or below the component.
  • Net label: label "VOUT" right — standalone net flag at the current cursor.
  • Comments: # at the start of a line (after leading whitespace).

7. Reserved words & escaping

Reserved at line start (positional): circuit (header), at:, net, wire, label.

Reserved in netlist mode: same header rules apply; all other lines are SPICE component lines.

Ground net aliases (netlist only): 0, gnd, GND, Gnd, ground, Ground — all treated as the same node.

Component IDs must match [a-zA-Z_][a-zA-Z0-9_]*. Spaces in values must be quoted: value="10 kΩ".


8. Common mistakes

You wroteParser saysFix
resistor right 1k (bare value without value=)1k is parsed as an unknown attribute flag and ignoredUse value="1k": resistor right value="1k"
at: R1.centercenter is not a recognized anchor suffix — cursor stays at current positionUse at: R1.end or at: R1.start
wire 40 (no direction)Direction defaults to right; length 40 is acceptedExplicit direction recommended: wire right 40
R1 vcc out 10k in positional modeLine matches the bare-type pattern; R1 is read as a type name, fails lookupIn positional mode, use R1: resistor right value="10k"
Q1 c b e (netlist, no model)Type defaults to npn from Q prefix — correctOK; add npn explicitly for clarity
net OUT then at: OUT without net OUT: dotOUT net exists but has no anchor; jump has no destinationUse net OUT: dot to register the cursor position
label VCC up (unquoted label)VCC is parsed as a direction token, then up — the label text is lostQuote the text: label "VCC" up

9. Grammar (EBNF)

document        = header statement*

-- Positional mode --
header          = "circuit" ( WS quoted-string )? NEWLINE
statement       = blank | comment | component | wire | at | net-decl | label-stmt

component       = ( id ":" WS )? type WS direction? attrs* NEWLINE
wire            = "wire" ( WS direction )? ( WS integer )? NEWLINE
at              = "at:" WS anchor NEWLINE
anchor          = id "." ( "start" | "end" )
                | id                          // net name anchor

net-decl        = "net" WS id NEWLINE         // declare net only
                | "net" WS id ":" WS "dot" NEWLINE  // declare + place dot

label-stmt      = "label" WS quoted-string ( WS direction )? NEWLINE

component-attr  = "value=" quoted-string
                | "label=" quoted-string
                | "at=" anchor
                | "length=" integer

direction       = "right" | "left" | "up" | "down"
type            = // any value from §2 component tables

-- Netlist mode --
netlist-header  = "circuit" ( WS quoted-string )? WS "netlist" NEWLINE
netlist-stmt    = id WS net-ref+ ( WS kv-pair )* NEWLINE
                | comment
net-ref         = id | "0"                    // net name or ground alias
kv-pair         = id "=" ( quoted-string | bare-value )

id              = [a-zA-Z_] [a-zA-Z0-9_]*
integer         = [0-9]+
quoted-string   = '"' any-char-but-quote* '"'
comment         = "#" any NEWLINE

Authoritative source: src/diagrams/circuit/parser.ts and src/diagrams/circuit/netlist.ts. If this diverges from the parser, the parser wins — please open an issue.


10. Standard compliance

Schematex circuit schematics follow IEEE Std 315-1975 / ANSI Y32.2 for component symbol shapes and IEC 60617 for international variants. The netlist syntax follows SPICE prefix conventions (Berkeley SPICE3 / LTspice / ngspice).

What is implemented today:

  • ✅ Full passive component set: resistor variants, capacitor variants, inductor variants, crystal, transformer
  • ✅ Sources and power: voltage source, current source, AC source, battery, VCC, four ground styles
  • ✅ Diode family: diode, zener, schottky, LED, photodiode, varactor, TVS, bridge rectifier
  • ✅ BJTs: NPN, PNP, Darlington NPN/PNP
  • ✅ FETs: NMOS/PMOS enhancement, NMOS depletion, N/P-channel JFET
  • ✅ Power semiconductors: IGBT, SCR, TRIAC, DIAC
  • ✅ Optoelectronics: phototransistor, optocoupler
  • ✅ Analog ICs: op-amp, comparator, Schmitt buffer, tri-state buffer, INA, generic IC, voltage regulator, DC-DC converter, 555 timer
  • ✅ Switches: SPST, SPDT, DPDT, push-NO, push-NC
  • ✅ Relays: coil, NO contact, NC contact
  • ✅ Electromechanical: motor, speaker, microphone, buzzer
  • ✅ Measurement: ammeter, voltmeter, wattmeter, oscilloscope
  • ✅ Annotations: wire, dot, label, port, test point, no-connect, antenna
  • ✅ Positional DSL: direction chaining, at: branching, net declarations
  • ✅ Netlist DSL: SPICE prefix mapping, model overrides, auto-ground synthesis
  • ⏳ Pin-level at: for BJT/FET/op-amp named pins (base, collector, plus, minus, out)
  • ⏳ Auto-routed wires in positional mode (routing around placed symbols)
  • ⏳ Bus wires with bit-width annotation (/8 slash)

References:

  • IEEE Std 315-1975 (ANSI Y32.2): Graphic Symbols for Electrical and Electronics Diagrams
  • IEC 60617: Graphical symbols for diagrams
  • SPICE3 User's Manual, UC Berkeley — netlist line format conventions


12. Roadmap

Planned — not yet parseable. Do not use these in generated DSL today; the parser will reject or ignore them.

  • Named pin anchors for multi-pin componentsat: Q1.base, at: U1.out, at: U1.plus so op-amp and BJT feedback loops can be wired without long wire detours.
  • Bus wirewire right bus=8 drawing a thick wire with a /8 bit-width slash annotation.
  • Auto-routed wiresconnect R1.end U1.minus letting the engine route the wire around placed symbols.
  • flip and reverse attributes — mirror or reverse a component's polarity/orientation along the direction axis.
  • dashed wire style — dashed line for RF shields, cable bundles, or virtual connections.
  • Hierarchical sheetsmodule "name" { … } grouping analogous to logic gate modules, for documenting multi-sheet schematics.

Track in the GitHub issues if you need any of these sooner.