The .coppa file format
The open, documented JSON format of a .coppa file, for reading and writing circuits from any language.
This page is the file format specification kept with Coppa’s source as docs/FILE-FORMAT.md, published here as it stands.
A .coppa file is one UTF-8 JSON document. It holds every circuit page with its parts, wires and probes, plus the run setup, graphs, window layout and the document's extras. The format is open: you can read and write it from any language, diff it in git and generate it from scripts.
- JSON Schema:
docs/coppa.schema.jsonin Coppa’s source (draft 2020-12).CoppaTests/Documents/FileSchemaTests.swiftchecks every bundled example, every lesson and a file with every section filled in against it, so the schema can't drift from what Coppa writes. - Source of truth:
Coppa/Documents/CoppaFile.swiftand theCodabletypes it uses (listed under each section below). - Uniform Type Identifier:
app.coppa.circuit(conforms topublic.json), extension.coppa.
Versions#
| Key | Now | Meaning |
|---|---|---|
version | 1 | The data layout. Bumped only when a change means an older Coppa can't read the file. |
formatVersion | 2 | How the text is laid out. 1 was plain JSONEncoder output; 2 is the canonical layout below. Coppa reads both the same way. Written for other tools; Coppa never needs it. |
New features add keys rather than change old ones, so version has stayed at 1. A file from a newer Coppa opens in an older one: unknown keys are skipped and the rest loads.
Reading rules (tolerant decoding)#
Coppa never refuses a file because one piece is odd. A reader should do the same:
- Missing key: use the default listed below. Almost every key is optional; the only required keys are a part's
name, a drawing'skind, a block pin'sname, a block reference'sdefinition, a canvas graph'straceand a layout window'stab. - Unreadable value (wrong type, unknown enum case): use the default for that key, not an error.
- Arrays are lossy: an element that can't be read is dropped and the others are kept, so one part from a newer Coppa doesn't lose the page.
- Unknown keys: ignore them.
- Unknown enums inside parts read as their safe value (an unknown
faultreads asnone, an unknowndamageasopen).
The schema sets additionalProperties: false so that it documents every key Coppa writes. Don't use that strictness to reject files in a reader.
Writing rules (canonical output)#
Coppa writes the same bytes for the same circuit, so files diff well (Coppa/Documents/CanonicalJSON.swift):
- Keys sorted alphabetically at every level.
- An object or array that fits in 100 characters stays on one line (a point, a wire, a probe); anything longer is spread out one entry per line, indented by two spaces.
- Numbers with floating-point noise (0.30000000000000004) are written to 15 significant digits. Whole numbers have no decimal point.
- Slashes aren't escaped. The file ends with a newline.
- Parts, wires and probes keep the order they were placed in. Adding a part adds lines at the end of its page, and moving or renumbering one changes only its lines.
- Settings left at their default are often left out (marked "omitted when default" below). Readers fill the same defaults back in.
Value types#
| Type | JSON | Example |
|---|---|---|
| point | [x, y] in schematic grid units (one grid square = 1) | [12, 4] |
| size | [width, height] | [16, 8] |
| range | [lower, upper] | [0, 0.001] |
| UUID | upper-case string with hyphens | "6F1C…-…" |
| date | number of seconds since 2001-01-01 00:00:00 UTC | 800000000 |
| data | Base64 string | "iVBORw0K…" |
| value text | a part value as typed, always with a full stop for decimals | "4.7k", "10u tol=5%" |
Part values, run times and SPICE text stay in POSIX number format whatever the Mac's region.
Top level (CoppaFile)#
| Key | Type | Default | Notes |
|---|---|---|---|
version | integer | 1 | See Versions. |
formatVersion | integer | — | See Versions. |
pages | array of page | [] | Circuit pages in tab order. |
selectedPage | integer | 0 | Index of the page in front when saved. |
analysis | analysis settings | defaults | What ▶ runs. |
generator | function generator | defaults | The bench function generator. |
runSetups | array of run setup | [] | Saved run configurations. |
activeRunSetup | integer | 0 | Index into runSetups. |
snap | boolean | true | Snap to grid. |
showGrid | boolean | false | |
blocks | array of block definition | [] | Subcircuits used in the file, so it opens anywhere. |
plots | object: page index ("0", "1" …) → plot settings | {} | Each page's graph. |
layout | layout | absent | How the window was laid out. Not part of the circuit. |
extras | extras | empty, omitted | Part numbers, attachments, comments, requirements, output jobs. |
lab | lab | absent, omitted when empty | A lesson's or teacher's lab sheet. |
studio | studio | empty, omitted | Lock, title block, variants, rules-check settings. |
symbols | array of drawn symbol | [], omitted when empty | Symbols drawn in the Symbol Editor or imported from KiCad, EAGLE or Altium, used in the file. |
Page (CoppaFile.Page)#
name (string, default "Untitled") and schematic.
Schematic (Schematic, Coppa/Models/Schematic.swift)#
| Key | Type | Default |
|---|---|---|
parts | array of part | [] |
wires | array of wire | [] |
probes | array of probe | [] |
temperature | number, °C | 27 |
signal | input signal | defaults |
buses | array of bus | omitted when empty |
notes | array of note | omitted when empty |
drawings | array of drawing | omitted when empty |
Wires connect wherever a wire end or corner meets a pin or another wire; there is no separate net list. Coppa works out nets from the geometry.
Part (PlacedPart)#
| Key | Type | Default | Notes |
|---|---|---|---|
id | UUID | new | |
name | string | required | Catalogue name ("Resistor", "TL072") or an imported model's name. |
reference | string | "" | R1, U1 … |
value | value text | "" | May carry extras such as tol=5%, tol=+80%/-20%, drift=1%. |
position | point | [0, 0] | |
rotation | integer | 0 | Quarter turns clockwise; omitted when 0. |
mirrored | boolean | false | Omitted when false. |
referenceOffset, valueOffset | point | [0, 0] | Labels dragged from their usual place; omitted when zero. |
closed | boolean | false | A switch that's closed. |
wiper | number 0–1 | 0.5 | A potentiometer's wiper; omitted when 0.5. |
wiperKey | string | "A" | The key that turns the wiper. |
block | block reference | absent | The part is a subcircuit. |
digital | digital settings | absent | Logic parts (gate inputs, widths, memory). |
device | device settings | absent | Microcontroller boards and modules. |
spiceModel | string | absent | An imported SPICE model, embedded so the file opens on another Mac. |
referenceLocked | boolean | false | Renumbering leaves it alone. |
hidesReference, hidesValue | boolean | false | Label hidden on the schematic. |
powerRating | number, W | absent | For over-power warnings. |
voltageRating | number, V | absent | For over-voltage warnings. |
options | part options | omitted when default |
Part options (PartOptions): disabled (left out of the netlist), fault (none, open, short, drift), drift (fraction, 0.2 = +20 %), ideal (ideal or real model), stimulus (a sensor's input or a motor's load), position (a rotary switch's position), blown (a fuse), damage (open or short, what overload did), charge (a battery's starting charge, 0–1). Each is omitted when default.
Digital settings (DigitalSettings, Coppa/Digital/GenericLogic.swift): inputs (gate inputs), inverted (bit mask of inverted inputs), bits (width), dataBits (memory data width), memory (RAM/ROM contents), switches (bit mask of DIP switches on), logicView (drawn as a logic symbol), code (a Verilog block's module or a script's Python), inputPorts and outputPorts (a script block's or script source's ports, such as A, B, D[3:0]), analogue (a script block that reads and drives volts), splitBuses (vector ports as one pin per bit), stateMachine (a state machine part's machine) and gateBlock (the id of the block of gates built from it).
A state machine (StateMachine, Coppa/Digital/StateMachine/StateMachine.swift) has inputs and outputs (signal names), states (each id, name, x, y in the editor, and outputs, the Moore outputs that are 1), transitions (each id, from, to, condition, a Verilog expression of the inputs that is empty for always, and outputs, the Mealy outputs that are 1), initial (a state id; absent for the first), style (moore or mealy) and encoding (binary, oneHot or gray). All of its keys are written.
Device settings (DeviceSettings, Coppa/Microcontrollers/DeviceSettings.swift): language (sketch, python, flowchart, firmware), source (program text), firmware (data, e.g. an Intel HEX image), firmwareName, flowchart, breakpoints (line numbers), watches (variable names), serialInput, readings (a module's settable readings by name), pressed (keys held), address (an I²C address), count (e.g. LEDs on a strip), boardView.
A flowchart (Flowchart) has setup and loop, each an array of blocks. A block (FlowBlock) has id, kind (pinMode, digitalWrite, analogWrite, digitalRead, analogRead, delay, print, set, decision, repeatTimes, wait), pin, value, variable, comparison, text, and the nested body and otherwise arrays. All block keys are written and read.
Wire, bus, probe, note, drawing#
- Wire (
Wire):id,points(corners), optionalcolour(blue,purple,pink,red,orange,yellow,green,mint,teal,cyan,indigo,brown,graphite). - Bus (
Bus):id,points,label(its members, e.g.D[0..7]orA[7:0]), andradix(hex,decimalorbinary, how its value is shown while simulating; omitted for hex). - Probe (
Probe):id,kind(voltage,current,power,differential,digital,reference),number,at(point), and optionalcolour(red,green,blue, each 0–1),label,tagOffset(point),partID(the part a current or power probe measures). - Note (
Note):id,at(top-left),text,kind(textortable; a table's cells are tab- and line-separated intext). - Drawing (
Drawing,Coppa/Annotation/Drawing.swift):id,kind(line,arrow,rectangle,ellipse,arc,bezier,image),points, and for an image,image(data: PNG, JPEG or PDF bytes).
Input signal (InputSignal)#
The page's signal source: amplitude (V), frequency (Hz), shape (Sine, Square, Triangle, Sawtooth, Custom), offset (V), duty (0–1), edge (fraction of a period), custom (one period of samples for Custom).
Run setup#
Analysis settings (AnalysisSettings, Coppa/Simulation/AnalysisSettings.swift):
| Key | Type | Notes |
|---|---|---|
kind | string | tran, ac, op or dc. Older files hold the display name ("Transient"), which still reads. |
stopTime | value text | Transient length, e.g. "20m". |
maxStep | value text | Empty means automatic. |
acStart, acStop | value text | AC sweep range in Hz. |
accuracy | string | Fast, Balanced or Precise. |
whenStuck | string | What to do when the solver can't converge: Explain the cause and suggest a fix, Retry automatically with safer settings, Stop and show the raw SPICE message. |
startFromZero | boolean | Skip the operating point. |
adaptiveStep | boolean | |
startupKick | boolean | Omitted when true. |
designScript | string | Omitted when empty. |
automaticWindow | boolean | Pick the run length from the circuit. |
dcSource, dcStart, dcStop, dcStep | string | DC sweep; each omitted when empty. |
Run setup (CoppaFile.RunSetup): name, detail, optional analysis (a kind code).
Function generator (FunctionGeneratorSettings): waveform (Sine, Square, Triangle, Ramp, Pulse), frequency (Hz), amplitude (V), offset (V), phaseDegrees, dutyCycle (%), highZLoad.
Subcircuits (Coppa/Hierarchy)#
- Block definition (
BlockDefinition):id,name,schematic(its inside),symbol(a block symbol, ornullfor an automatic one),isSheet(a hierarchical sheet rather than a reusable block). - Block reference (
BlockRef, on a part):definition(the definition'sid, required),symbol,revision. - Block symbol (
BlockSymbol):pinsand optionalwidth(grid squares; absent fits the pin names). - Block pin (
BlockPin):name(required, matches a port inside),side(left,right,top,bottom). - A block symbol may also carry
drawn, a drawn symbol worn instead of the plain box (a custom look). - Drawn symbol (
DrawnSymbol,Coppa/Models/Symbols/DrawnSymbol.swift):id,name,reference(prefix such asU),shapes(drawings:line,rectangle,ellipse,arcthrough its third point,bezier),texts,pins, optionalsource(where it was imported from),model(a SPICE model name) andnotes. Grid units, y down, around the part's origin. - Symbol text (
SymbolText):id,text,at,size(grid units). - Symbol pin (
SymbolPinDef):id,name,number,direction(passive,input,output,bidirectional,power,openCollector,unconnected),at(where wires meet it, a whole grid point),side(the body side it leaves from),length(grid units), andmodelPin(the block Port or SPICE pin it stands for; omitted when it's the pin's name).
Graphs (plots, PlotSettings, Coppa/Views/Graph/GraphTools.swift)#
| Key | Type | Notes |
|---|---|---|
layout | string | "scope" or another graph layout. |
hidden | array of UUID | Probes not shown. |
expressions | array of string | Added traces, e.g. "V(out)/V(in)". |
measurements | array of measurement | |
limits | object: trace → limit line | |
notes | array of graph note | |
linkedX | boolean | Stacked charts share one time axis. |
axisLocks | object: chart → axis lock | Charts: "time", a stacked pane's first trace, "gain", "phase", "dc". |
scopeMeasures | array of string | peakToPeak, rms, mean, maximum, minimum, amplitude, frequency, period, duty, rise, fall. |
names | object: trace key → name | Friendly trace names. |
canvasGraphs | array of canvas graph | Live graphs on the schematic. |
- Measurement (
MeasureDefinition,Coppa/Simulation/Measurements.swift, like SPICE.meas):id,name,function(Average,RMS,Minimum,Maximum,Peak to Peak,Integral,Slope At,Value At,Value When,When,Delay,Rise Time,Fall Time),expression, optional windowfromandto(s), optionalat(s), three crossingswhen,triggerandtarget, andlowFractionandhighFractionfor rise and fall times. All but the optional keys are required. - Crossing (
Crossing):expression,level,edge(Rising,Falling,Either),occurrence(1 = first, 0 = last). - Limit line (
LimitLine): optionallowerandupper. - Graph note (
GraphNote):id,time,value,text,trace, all required. - Axis lock (
AxisLock): optionalxandyranges. - Canvas graph (
CanvasGraph):id,trace(a probe's UUID, required),at(point),size.
Window layout (layout, LayoutState, Coppa/Documents/LayoutState.swift)#
Only how the window looked; a reader that doesn't show windows can ignore it.
| Key | Type | Notes |
|---|---|---|
panes | array of pane | Editors in the window. |
focused | integer | Index of the focused pane. |
split | [x, y] | Divider positions, 0–1. |
sidebar | boolean | |
navigator | string | The sidebar tab ("parts" …). |
inspectors | array of editor kind | Kinds of editor that show the inspector. |
results | boolean | Results area shown. |
resultsHeight | number | Points. |
resultsTab | string | waveforms, measurements or log. |
windows | array of window | Tabs open in windows of their own. |
- Editor kind:
circuit,graph,instrument,grapher. - Tab:
kind,page(index intopages; -1 for the Grapher), optionalinstrument(its stable name, e.g."oscilloscope"). - Pane:
tabs,selected,tile([column, row, columns, rows]on a 2 × 2 grid),views. - View:
tab(index into the pane's tabs),pan([x, y]),zoom. - Window:
tab(required) and optionalframe([x, y, width, height]in screen points).
Extras (extras, DocumentExtrasRecord, Coppa/Documents/DocumentExtras.swift)#
Each key is omitted when empty.
sourcing: object of partid→ part sourcing, for the bill of materials. Part sourcing (PartSourcing):mpn,manufacturer,lcsc,footprint.attachments: files kept inside the circuit (datasheets, photos). Attachment (Attachment):id,name(file name),typeIdentifier(a UTI such ascom.adobe.pdf),data(the file's bytes, Base64), optionalpartID(the part it belongs to),added(date). One attachment is at most 20 MB and all of them together at most 50 MB.comments: review comments. Comment (ReviewComment):id,page(page index),at(point),text,author,date,resolved.requirements: pass/fail specs checked after a run. Requirement (Requirement):id,text,measurement(a measurement's name), optionalminimumandmaximum,page.outputJobs: one-click exports. Output jobs (OutputJobs):outputs(pdf,png,svg,bom,jlcpcb,netlist,circuitikz), optionalfolderBookmark(a macOS security-scoped bookmark, data) andfolderPath.
Lab (lab, LabRecord, Coppa/Learning/LabRecord.swift)#
A lesson or a teacher's lab sheet: title, instructions, optional lessonID (a built-in lesson), questions, lockedValues (part id → value the student can't change), hiddenInstruments (instrument stable names), isStudentCopy.
Question (LabQuestion): id, prompt, expected (number), tolerance (fraction, default 0.05), unit, answer (the student's answer as typed).
Studio (studio, StudioRecord, Coppa/Annotation/StudioState.swift)#
Each key is omitted when default.
locked: the circuit is locked against edits (switches still flip).titleBlock: Title block (TitleBlockInfo):title,author,company,revision, optionaldate,showsOnCanvas.variants: build variants. Variant (PartVariant,Coppa/Annotation/Variants.swift):id,name,notFitted(part ids left off the board),values(partid→ value for this variant).activeVariant: the variant in use (UUID).disabledRules: rules-check rules turned off, by rule id.ignoredIssues: rules-check findings marked as ignored, by issue key.
Example#
A 1 kΩ / 1 µF RC low-pass on a 5 V step, as Coppa writes it (ids shortened here; real files hold full UUIDs):
{
"activeRunSetup": 0,
"analysis": {
"acStart": "10", "acStop": "100k", "accuracy": "Balanced", "adaptiveStep": true, "automaticWindow": true,
"kind": "tran", "maxStep": "", "startFromZero": false, "stopTime": "10m",
"whenStuck": "Explain the cause and suggest a fix"
},
"blocks": [],
"formatVersion": 2,
"generator": {
"amplitude": 1, "dutyCycle": 50, "frequency": 1000, "highZLoad": true, "offset": 0, "phaseDegrees": 0,
"waveform": "Sine"
},
"pages": [
{
"name": "RC filter",
"schematic": {
"parts": [
{"id": "A1…", "name": "DC supply", "position": [4, 8], "reference": "V1", "value": "5"},
{"id": "B2…", "name": "Resistor", "position": [10, 4], "reference": "R1", "value": "1k"},
{"id": "C3…", "name": "Capacitor", "position": [16, 8], "reference": "C1", "rotation": 1, "value": "1u"},
{"id": "D4…", "name": "Ground", "position": [10, 14], "reference": "", "value": ""}
],
"probes": [{"at": [16, 4], "id": "E5…", "kind": "voltage", "label": "Vout", "number": 1}],
"signal": {"amplitude": 0.01, "custom": [], "duty": 0.5, "edge": 0.005, "frequency": 1000, "offset": 0, "shape": "Sine"},
"temperature": 27,
"wires": [
{"id": "F6…", "points": [[4, 4], [8, 4]]},
{"id": "G7…", "points": [[12, 4], [16, 4], [16, 6]]}
]
}
}
],
"plots": {},
"runSetups": [],
"selectedPage": 0,
"showGrid": false,
"snap": true,
"version": 1
}
The smallest file Coppa opens is {"pages": [{"name": "Empty", "schematic": {}}]}; every other key takes its default.
Changing the format#
- Add keys; don't rename or repurpose them. Give every new key a default and decode it with
c.value(_:default:),c.optional(_:)orc.lossyArray(_:)so older files still open. - Leave a new key out when it holds its default, so existing files don't change when they're saved again.
- Add the key to
docs/coppa.schema.jsonand to this document.FileSchemaTestsfails until both know about it. - Bump
CoppaFile.currentVersiononly for a change an older Coppa can't read, and say here what changed.
Applies to Coppa 0.1 Preview 14. Last updated 22 November 2026.