Read Exact Stitch Counts from DST and PES Files in Your Browser
When a customer or digitizer sends you a Tajima (.dst) or Brother (.pes) file, your operating system only shows the file size in kilobytes—not how many stitches, color changes, or trims are inside. Dropping the file into the reader above parses every binary stitch command right on your computer and immediately reports normal stitches, jumps, trims, color changes, thread blocks, width × height in both inches and millimeters, estimated machine run time, and per-piece pricing.
Because the file reader runs inside a local Web Worker in your browser, your customer's artwork never uploads to any external server. Files up to 10 MB are decoded on your device in fractions of a second.
How Tajima DST Files Store Stitches, Jumps, and Trims
As documented in the EduTech Wiki DST specification and implemented in the open-source pyembroidery library, every Tajima .dst file consists of two parts:
-
A fixed 512-byte ASCII header: The first 125 bytes store carriage-return-delimited tags such as
LA:(design label),ST:(total record count),CO:(color change count), and+X/-X/+Y/-Yextents, padded with spaces (0x20) out to 512 bytes. Standard DST headers do not store thread colors unless rare extendedTC:tags are present. -
A body of 3-byte balanced ternary stitch records: Starting at byte offset
512, every command occupies exactly 3 bytes. Each 3-byte record encodes a relative movement(dx, dy)using balanced ternary weights of±1,±3,±9,±27, and±81in units of0.1 mm(so10units equal1.0 mmand254units equal1.0 inch), giving a maximum single movement of±121units (12.1 mm).
The highest bits of the third byte determine what kind of command the 3-byte record represents:
- Normal stitch (
0b00000011mask): Lowers the needle to form a stitch at the new coordinate. This is the number used for stitch-based pricing. - Jump stitch (
0b10000011mask): Moves the pantograph without stitching (unless sequin mode is active). - Color change / Stop (
0b11000011mask): Signals the machine to stop or switch to the next needle bar. - Sequin mode (
0b01000011mask): Toggles sequin attachment mode. - End of pattern (
0b11110011/0xF3): Marks the end of the design.
Notably, the DST format does not have a dedicated bit for a thread trim. Instead, digitizing software triggers a machine trim by inserting consecutive jump commands—typically 3 jumps in a row. Our reader follows the same trim-interpolation rule as pyembroidery: when 3 consecutive jump records occur after stitching, a trim is counted, and if a digitizer inserted fake zero-displacement jumps (such as +2,+2, -4,-4, +2,+2) solely to force a trim, those zero-sum jumps are clipped so your jump count stays accurate.
Why You Should Never Trust a File Header Count Alone
Many quick online estimators only read the ST: and CO: text strings in the first 125 bytes of a DST header. That causes two real problems:
- First, the DST header's
ST:field counts all 3-byte records in the file—including jumps, color changes, and the end record—not just normal sewing stitches. For example, in the open-sourceembroidermodder.dstsample fixture, the header statesST: 3487, whereas the actual stitch records contain3,407normal stitches,30jumps, and12interpolated trims. - Second, some exporting software writes stale or off-by-one values in the header. In the open-source
random1-me.dsttest file frombroideryfab/embroidery-ksy, the header reportsCO: 10color changes, while the actual stitch records contain only9color changes (10 thread blocks).
To protect your quotes, this tool always computes normal stitches, jumps, trims, color changes, and width × height directly from the stitch records, and displays a warning banner whenever a file's header disagrees with the actual stitch data.
How Brother PES Files Store Stitches and Thread Colors
As documented in the EduTech Wiki PES and PEC specifications, a Brother .pes file contains two sections: a versioned #PES design section (such as #PES0001, #PES0060, or #PES0100) and a hardware PEC block whose 4-byte little-endian byte offset is stored right at byte 8 of the file.
Because Brother and Bernina machines rely on the PEC section for backward compatibility across all PES versions, reading the PEC stitch block lets this calculator support PES v1 through v10 seamlessly:
- Short-form coordinates (1 byte): If the top bit of a coordinate byte is
0, the remaining 7 bits encode a signed two's-complement movement between-64and+63(in0.1 mmunits). - Long-form coordinates (2 bytes): If the top bit is
1(0x80), the next bits carry control flags—0x10for a jump and0x20for a trim—while the low 12 bits encode a signed movement between-2048and+2047. - Color changes and End: A
0xFE 0xB0byte pair followed by a 1-byte index marks a color change, and0xFF 0x00marks the end of the stitch list. - Thread colors: The reader extracts custom RGB thread definitions from PES v5–v10 headers when present, and maps PEC palette bytes against the 64-color Brother thread chart.
From Stitch Count to Machine Time and Job Price
Once your file is loaded—for instance, the star.pes sample fixture with 2,550 normal stitches, 1 color change (2 colors), 2 jumps, and dimensions of 59.1 × 62.3 mm (2.33" × 2.45")—the calculator immediately computes machine run time and per-piece pricing:
- Machine time at 650 spm:
2,550 ÷ 650 + (1 × 0.5 min) + 1.0 min hooping = 5.42 minutes per piece - Base decoration at starting rates:
(2,550 ÷ 1,000) × $1.50 + $1.00 = $4.825, which is raised to the$5.00per-piece minimum.
Frequently Asked Questions
Can I estimate stitch count if I only have an image and not a DST or PES file?
An image file (such as a PNG or JPEG) contains pixels rather than stitch coordinates, so true stitch count depends on how the digitizer sets fill density, underlay, and satin stitch width. If you know the approximate stitch count from your digitizer, click "Enter stitch count instead" to price the job manually.
Why do DST files show default colors in the preview while PES files show exact thread colors?
Standard Tajima DST files only record "color change" stop commands without storing RGB thread colors (unless rare TC header tags are used). Brother PES files store a Brother PEC color palette table and, in PES v5 and newer, RGB thread definitions.
What is the maximum file size the browser reader accepts?
The reader accepts .dst and .pes files up to 10 MB, which is large enough for multi-hundred-thousand-stitch jacket backs while keeping browser memory fast and responsive.