Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including json-midi-encoder with all npm packages installed. Try it out:

var jsonMidiEncoder = require("json-midi-encoder")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

json-midi-encoder v3.2.9

This module encodes a JSON representation of MIDI data into a binary MIDI file.


This module encodes a JSON representation of MIDI data into a binary MIDI file.

tests dependencies version

By using this module it is possible to encode a JSON representation of a MIDI file into its binary counterpart. That JSON representation can either be created from scratch or produced by parsing an existing file with the midi-json-parser.


This module is distributed as package on npm. It can be installed by running the following command:

npm install json-midi-encoder

The only exported function is called encode(). It expects to receive a JSON representation as its only parameter. It returns a Promise which hopefully resolves with an ArrayBuffer containing the binary MIDI file. Here is a little example.

import { encode } from 'json-midi-encoder';

const json = {
    division: 480,
    format: 1,
    tracks: [
                delta: 0,
                trackName: 'example'
            // ... there are probably more events ...
                delta: 0,
                endOfTrack: true
        // ... maybe there are more tracks ...

    .then((midiFile) => {
        // midiFile is an ArrayBuffer containing the binary data.

To see what kind of events this module can handle, you may want to have a look at the JSON files used to test this module. There is also a TypeScript interface which describes the JSON representation.

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free