⚠️ NOTE: ChordJS has been merged into ChordSheetJS
ChordJS will not receive any more updates, although it will remain on NPM. To benefit from new features, please use ChordSheetJS instead.
npm install chordsheetjs
or:
yarn add chordsheetjs
import Chord from 'chordsheetjs';
const chord = Chord.parse('Em');
A simple JavaScript chord parsing and manipulation tool
ChordJS
is on npm, to install run:
npm install chordjs
or:
yarn add chordjs
Load with import
(es2015):
var Chord = require('chordjs').default;
import Chord, { parse } from 'chordjs';
const chord = parse('Ebsus4/Bb');
Parse numeric chords (Nashville system):
const chord = parse('b1sus4/#3');
Use #toString() to convert the chord to a chord string (eg Dsus/F#)
const chord = parse('Ebsus4/Bb');
chord.toString(); // --> "Ebsus4/Bb"
var chord2 = chord.clone();
Normalizes keys B#, E#, Cb and Fb to C, F, B and E
const chord = parse('E#/B#'),
normalizedChord = chord.normalize();
normalizedChord.toString(); // --> "F/C"
Convert # to b and vice versa
const chord = parse('Eb/Bb');
const chord2 = chord.switchModifier();
chord2.toString(); // --> "D#/A#"
Set the chord to a specific modifier (# or b)
const chord = parse('Eb/Bb');
const chord2 = chord.useModifier('#');
chord2.toString(); // --> "D#/A#"
const chord = parse('Eb/Bb');
const chord2 = chord.useModifier('b');
chord2.toString(); // --> "Eb/Bb"
const chord = parse('Eb/Bb');
const chord2 = chord.transposeUp();
chord2.toString(); // -> "E/B"
const chord = parse('Eb/Bb');
const chord2 = chord.transposeDown();
chord2.toString(); // -> "D/A"
const chord = parse('C/E');
const chord2 = chord.transpose(4);
chord2.toString(); // -> "E/G#"
const chord = parse('C/E');
const chord2 = chord.transpose(-4);
chord2.toString(); // -> "Ab/C"
const numericChord = parse('2/4');
const chordSymbol = toChordSymbol(numericChord, 'E');
chordSymbol.toString(); // -> "F#m/A"