User Rating 0.0
Total Usage 0 times
Configure your ticket and click Generate
Is this tool helpful?

Your feedback helps us improve.

About

Train ticket generation requires precise layout geometry. A misaligned barcode or truncated passenger name renders a ticket unreadable by both humans and scanners. This generator replicates the Hacker Zephyr boarding pass format - a retro-styled rail ticket with fields for passenger name, origin, destination, car number, seat assignment, and a unique ticketID encoded as a 128-bit hexadecimal string. The barcode strip uses Code 128 subset B encoding logic mapped to vertical bar widths. All rendering occurs on an HTML Canvas element at 1200 × 460 pixels, exported as a lossless PNG. No server round-trip. No chromium dependency. The tool assumes standard rail ticket proportions at a 2.6:1 aspect ratio.

Limitations: the barcode is decorative and does not conform to GS1 scanning standards. The QR-style matrix in the corner is procedurally generated from the ticket hash and is not scannable. For actual transit use, integrate with a certified barcode library. This tool is designed for event passes, hackathon credentials, and creative projects where visual fidelity matters more than machine readability.

ticket generator hacker zephyr train ticket boarding pass hack club png generator custom ticket

Formulas

The ticket ID is derived from the Web Crypto API random value generator:

ticketID = hex(crypto.getRandomValues(Uint8Array[8]))

Where each byte is converted to a zero-padded hexadecimal pair, producing a 16-character string with 264 possible combinations.

The decorative barcode encodes the ticket ID using a simplified Code 128B bar-width mapping:

barWidthi = 1 + (charCodeAt(ticketID[i]) mod 3)

Each character of the ID maps to a bar of width 1, 2, or 3 pixels, alternating between filled and blank bars. The total barcode strip spans the ticket stub width.

The decorative matrix grid uses a hash-seeded pattern:

cell(r, c) = (charCodeAt(ticketID[(r × cols + c) mod 16]) + r × c) mod 2

Where r = row index, c = column index, and the result determines fill (1) or empty (0). This produces a deterministic, reproducible pattern unique to each ticket.

Reference Data

FieldFormatMax LengthExampleNotes
Passenger NameUppercase Alpha24 charsORPHEUS HACKSWORTHAuto-truncated with ellipsis
Origin StationTitle Case20 charsBurlington, VTFree text input
DestinationTitle Case20 charsLos Angeles, CAFree text input
Departure DateYYYY-MM-DD10 chars2024-07-15ISO 8601 format
Departure TimeHH:MM5 chars09:3024-hour clock
Car NumberInteger1 - 997Leading zero added if single digit
SeatAlpha + Number4 charsA12Row letter + seat number
Ticket ClassEnum - HACKERHACKER, FIRST, COACH, SLEEPER
Ticket IDHex String16 chars7A3F..B2C1Auto-generated, cryptographically random
Canvas WidthPixels12001200Fixed export resolution
Canvas HeightPixels460460Fixed export resolution
Barcode TypeDecorative Code 128B64 bars - Visual only, not scannable
Color ThemeHSL Palette - Deep Purple6 preset themes available
Export FormatPNG - ticket.pngLossless, transparent-free
DPI Equivalent144 PPI - - Retina-ready at 2x

Frequently Asked Questions

The barcode uses a simplified Code 128B visual mapping that produces aesthetically correct bar patterns but omits the start/stop characters, checksum digit, and quiet zones required by ISO/IEC 15417. Adding full GS1 compliance would require implementing the complete Code 128 state machine with modulo-103 check characters. This generator prioritizes visual fidelity for event and hackathon use over machine readability.
The ticket renders at 1200 × 460 pixels. At standard print DPI of 150, this yields approximately 8 × 3 inches - suitable for a physical ticket or badge insert. For higher print quality, the canvas could be scaled to 2400 × 920 at 300 DPI, but the current resolution is optimized for screen display and standard inkjet output.
The ticket ID is 64 bits of cryptographic randomness sourced from crypto.getRandomValues(). The probability of collision follows the birthday problem: for n tickets, collision probability P 1 en2/265. You would need approximately 4.3 billion tickets before reaching a 50% collision chance. For hackathon-scale events this is effectively zero.
No. Each generation produces a new cryptographic ticket ID, which changes the barcode pattern and matrix grid. All other visual elements (name, stations, date) will be identical, but the ticket ID is always fresh. To reproduce a specific ticket, you would need to save and re-import the exact ticket ID - a feature not currently exposed in the UI.
Names longer than 24 characters are truncated with an ellipsis. The Canvas API measureText() method is used to check pixel width against the available name field area (380 pixels). If overflow is detected, characters are removed from the end until the text plus ellipsis fits. Short names are rendered at full size without scaling.