Threadsmith Stitch File Writer
Write DST, PES, JEF or EXP embroidery machine files from a stitch list or a Threadsmith project.
Try an example: Tiny square outline with a jump and a colour change → DST · Template project (name tag) → Melco EXP · Template project (botanical leaf) → Brother PES with thread colours · Template project (heart appliqué) → Janome JEF
How it works
Encodes stitches as a Tajima DST (512-byte header, balanced-ternary 3-byte records, jumps split to ≤ 12.1 mm, colour changes, trims as zero-sum jumps, END), Brother PES (v1 wrapper around the PEC stitch block with thread palette indices and thumbnails, real trim flags), Janome JEF (header with hoop, extents and Janome thread indices) or Melco EXP file. The file is decoded again to verify every stitch position before you download it.
- Coordinates are rounded to 0.1 mm on absolute positions, so rounding never accumulates; each move becomes the difference to the previous rounded position.
- DST: each axis is written in balanced ternary with digits for 1, 3, 9, 27 and 81 (±121 max). Byte 3 = 0x03 | flags: 0x80 jump, 0xC0 colour change; END = 00 00 F3. Longer moves are split into equal records. Y is inverted (DST is y-up).
- Trims are written as three jumps (+2,+2) (−4,−4) (+2,+2) that cancel out — the convention machines use to trigger a trim after a run of jumps.
- Header: LA label, ST record count, CO colour changes, ±X/±Y extents in 0.1 mm, AX/AY end offset, MX/MY 0, PD ******, 0x1A, padded with spaces to 512 bytes.
- EXP: 2 signed bytes per stitch (±127), 0x80 0x04 dx dy jump, 0x80 0x01 colour change; trims as three zero-sum jumps.
- PES: "#PES0001" + PEC offset + empty v1 object section, then the PEC block every Brother/Babylock machine reads: 512-byte header with label, colour count and the nearest of the 64 PEC palette threads per colour block; stitches as 7-bit short or 12-bit long moves (0x1000 jump, 0x2000 trim flag), FE B0 colour change, FF end; 48×38 1-bit thumbnails. Y is down.
- JEF: 116-byte little-endian header (stitch offset, date, colour and point counts, hoop code, extents, edge distances to the 110×110 / 50×50 / 140×200 / custom hoops) + nearest Janome thread index per colour; stitches as 2 signed bytes (y up), 80 02 jump, 80 01 colour change, 80 10 end; trims as a zero jump.
DST and EXP carry no thread colours; PES and JEF store the nearest colour of the machine’s own thread chart, which is only an approximation. Use the colour list from Threadsmith to thread the needles. Test on scrap fabric first.
Sources
- Embroidery format DST (header fields, ternary stitch encoding, control codes, trim convention) (EduTech Wiki, University of Geneva)
- Embroidery format EXP (2-byte two’s-complement stitches, 0x80 control codes) (EduTech Wiki, University of Geneva)
- pyembroidery – reference readers/writers for DST, EXP, PES/PEC and JEF (EmbroidePy)
- Embroidery format PES / PEC (PEC header, 7/12-bit stitch encoding, thread palette, thumbnails) (EduTech Wiki, University of Geneva)
- Ink/Stitch manual – stitch types, underlay, pull compensation (Ink/Stitch project)
- Felzenszwalb & Huttenlocher, Distance Transforms of Sampled Functions, Theory of Computing 8 (2012)
For scripts and AI agents
- JSON API:
POST https://threadsmithstitchfile.usefulweb.app/api/v1/calculate(same calculation as this page) - Interface description: OpenAPI 3.1 · AI guide: llms.txt
- MCP server (Streamable HTTP):
https://threadsmithstitchfile.usefulweb.app/mcp· tool namethreadsmith_stitch_file
Example request
curl -s -X POST https://threadsmithstitchfile.usefulweb.app/api/v1/calculate \
-H 'content-type: application/json' \
-d '{"format":"dst","label":"SQUARE","stitches":"[[0,0],[10,0],[10,10],[0,10],[0,0],[30,0,\"jump\"],[30,0,\"color\"],[30,0],[40,5],[30,10]]"}'Related tools
- Threadsmith Digitizer – Turn shapes, SVG paths, text or a whole project into embroidery stitches with stats and preview.
- Threadsmith Design Stats – Stitch count, colours, trims, thread, sewing time and density of a DST, PES, JEF or EXP file.