MIDI to JSON Converter
Convert MIDI files to structured JSON and back. Parse binary MIDI data, inspect tracks, notes, and events, then export or reconstruct MIDI files.
About
Standard MIDI Files (SMF) store musical performance data in a compact binary format defined by the MIDI Manufacturers Association. The format encodes delta times as variable-length quantities (VLQ), packs channel messages into status bytes with running status optimization, and nests everything inside MThd and MTrk chunks. Misinterpreting a single byte offset corrupts the entire event stream. This tool performs real binary parsing of .mid files into human-readable JSON, preserving every meta event, control change, and timing value. The reverse operation reconstructs valid MIDI binaries from JSON with correct chunk lengths and VLQ encoding. Note: this parser handles SMF Format 0, 1, and 2 files, but Format 2 (independent sequences) is rare and some DAWs may not load it correctly.
Formulas
MIDI files encode timing deltas using Variable-Length Quantity (VLQ) encoding. Each byte uses 7 data bits and 1 continuation bit.
Tempo conversion from microseconds per quarter note to BPM:
Chunk structure follows the pattern: 4-byte type identifier (MThd or MTrk) followed by a 4-byte big-endian unsigned integer for chunk data length, then the raw chunk data.
Where type = chunk identifier, length = size of data in bytes (big-endian 32-bit unsigned), data = chunk payload. Pitch bend value is a 14-bit number assembled from two 7-bit data bytes:
Reference Data
| MIDI Event Type | Status Byte | Data Bytes | Description |
|---|---|---|---|
| Note Off | 0x8n | 2 | Release note on channel n |
| Note On | 0x9n | 2 | Press note (velocity 0 = note off) |
| Poly Aftertouch | 0xAn | 2 | Per-note pressure change |
| Control Change | 0xBn | 2 | Controller number + value (0 - 127) |
| Program Change | 0xCn | 1 | Instrument/patch selection |
| Channel Aftertouch | 0xDn | 1 | Channel-wide pressure |
| Pitch Bend | 0xEn | 2 | 14-bit value, center = 8192 |
| SysEx Start | 0xF0 | Variable | System Exclusive message begin |
| SysEx End | 0xF7 | Variable | System Exclusive continuation/end |
| Meta: Sequence Number | 0xFF 0x00 | 2 | Track sequence identifier |
| Meta: Text Event | 0xFF 0x01 | Variable | Arbitrary text annotation |
| Meta: Copyright | 0xFF 0x02 | Variable | Copyright notice string |
| Meta: Track Name | 0xFF 0x03 | Variable | Name of the track |
| Meta: Instrument | 0xFF 0x04 | Variable | Instrument name for track |
| Meta: Lyric | 0xFF 0x05 | Variable | Lyric text synchronized to events |
| Meta: Marker | 0xFF 0x06 | Variable | Rehearsal marker or section label |
| Meta: Cue Point | 0xFF 0x07 | Variable | Cue for external synchronization |
| Meta: Channel Prefix | 0xFF 0x20 | 1 | Associate channel with following meta events |
| Meta: End of Track | 0xFF 0x2F | 0 | Mandatory track terminator |
| Meta: Set Tempo | 0xFF 0x51 | 3 | Microseconds per quarter note |
| Meta: SMPTE Offset | 0xFF 0x54 | 5 | Starting SMPTE time code |
| Meta: Time Signature | 0xFF 0x58 | 4 | Numerator, denominator power, clocks, 32nds |
| Meta: Key Signature | 0xFF 0x59 | 2 | Sharps/flats count + major/minor flag |
| Meta: Sequencer Specific | 0xFF 0x7F | Variable | Proprietary sequencer data |