
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
tonal is a music theory library. Contains functions to manipulate tonal
elements of music (note, intervals, chords, scales, modes, keys). It deals with
abstractions (not actual music or sound).
tonal is implemented in Typescript and published as a collection of Javascript
npm packages.
It uses a functional programming style: all functions are pure, there is no data mutation, and entities are represented by data structures instead of objects.
import { Interval, Note, Scale } from "tonal";
Note.midi("A4"); // => 60
Note.freq("a4").freq; // => 440
Note.accidentals("c#2"); // => '#'
Note.transpose("C4", "5P"); // => "G4"
Interval.semitones("5P"); // => 7
Interval.distance("C4", "G4"); // => "5P"
Scale.get("C major").notes; // =>["C", "D", "E", "F", "G", "A", "B"];
Install all packages at once:
npm install --save tonal
Tonal is compatible with both ES5 and ES6 modules, and browser.
import:import { Note, Scale } from "tonal";
require:const { Note, Scale } = require("tonal");
You can use the browser version from jsdelivr CDN directly in your html:
<script src="https://cdn.jsdelivr.net/npm/tonal/browser/tonal.min.js"></script>
<script>
console.log(Tonal.Key.minorKey("Ab"));
</script>
Or if you prefer, grab the minified browser ready version from the repository.
tonal includes all published modules.
Although the final bundle it is small, you can reduce bundle sizes even more by installing the modules individually, and importing only the functions you need.
Note that individual modules are prefixed with @tonaljs/. For example:
npm i @tonaljs/note
import { transpose } from "@tonaljs/note";
transpose("A4", "P5");
Generally, you just need to install tonal package (before it was called @tonaljs/tonal).
The API documentation is inside README.md of each module 👇
Read contributing document. To contribute open a PR and ensure:
This library takes inspiration from other music theory libraries:
Showcase of projects that are using Tonal:
Thank you all!
Add your project here by editing this file
FAQs
tonaljs music theory library
The npm package tonal receives a total of 5,866 weekly downloads. As such, tonal popularity was classified as popular.
We found that tonal demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.