# chordjs

> A simple JavaScript chord parsing and manipulation tool

Latest version **2.0.1** (published 2021-08-18) · SEE LICENSE IN LICENSE license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install chordjs
pnpm add chordjs
yarn add chordjs
bun add chordjs
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 2.0.1 |
| Published | 2021-08-18 |
| First published | 2016-02-03 |
| Weekly downloads | 0 |
| License | SEE LICENSE IN LICENSE |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 139 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 32 |
| Author | Martijn Versluis |
| Maintainers | martijnversluis |

## Links

- npm: https://www.npmjs.com/package/chordjs
- Repository: https://github.com/martijnversluis/ChordJS
- Issues: https://github.com/martijnversluis/ChordJS/issues
- npm.io page: https://npm.io/package/chordjs

## Recent versions

- 2.0.1 (latest) — 2021-08-18
- 2.0.0 — 2021-06-18
- 1.1.1 — 2018-05-10
- 1.2.0 — 2017-08-08
- 1.1.0 — 2017-06-05
- 1.0.0 — 2016-02-03

## README

# ChordJS [![Build Status](https://travis-ci.org/martijnversluis/ChordJS.svg?branch=master)](https://travis-ci.org/martijnversluis/ChordJS) [![npm version](https://badge.fury.io/js/chordjs.svg)](https://badge.fury.io/js/chordjs) [![Code Climate](https://codeclimate.com/github/martijnversluis/ChordJS/badges/gpa.svg)](https://codeclimate.com/github/martijnversluis/ChordJS)

A simple JavaScript chord parsing and manipulation tool

## ⚠️ NOTE: These are the V2 docs. The V1 docs are [here](https://github.com/martijnversluis/ChordJS/tree/v1.1.1#readme).

## Installation

`ChordJS` is on npm, to install run:

```bash
npm install chordjs
```

or:

```bash
yarn add chordjs
```

Load with `import` (es2015):

```javascript
var Chord = require('chordjs').default;
import Chord, { parse } from 'chordjs';
```

## Functionalities

### Parse

```javascript
const chord = parse('Ebsus4/Bb');
```

Parse numeric chords (Nashville system):

```javascript
const chord = parse('b1sus4/#3');
```

### Display with #toString

Use #toString() to convert the chord to a chord string (eg Dsus/F#)

```javascript
const chord = parse('Ebsus4/Bb');
chord.toString(); // --> "Ebsus4/Bb"
```

### Clone

```javascript
var chord2 = chord.clone();
```

### Normalize

Normalizes keys B#, E#, Cb and Fb to C, F, B and E

```javascript
const chord = parse('E#/B#'),
    normalizedChord = chord.normalize();
normalizedChord.toString(); // --> "F/C"
```

### Switch modifier

Convert # to b and vice versa

```javascript
const chord = parse('Eb/Bb');
const chord2 = chord.switchModifier();
chord2.toString(); // --> "D#/A#"
```

### Use specific modifier

Set the chord to a specific modifier (# or b)

```javascript
const chord = parse('Eb/Bb');
const chord2 = chord.useModifier('#');
chord2.toString(); // --> "D#/A#"
```

```javascript
const chord = parse('Eb/Bb');
const chord2 = chord.useModifier('b');
chord2.toString(); // --> "Eb/Bb"
```

### Transpose up

```javascript
const chord = parse('Eb/Bb');
const chord2 = chord.transposeUp();
chord2.toString(); // -> "E/B"
```

### Transpose down

```javascript
const chord = parse('Eb/Bb');
const chord2 = chord.transposeDown();
chord2.toString(); // -> "D/A"
```

### Transpose

```javascript
const chord = parse('C/E');
const chord2 = chord.transpose(4);
chord2.toString(); // -> "E/G#"
```

```javascript
const chord = parse('C/E');
const chord2 = chord.transpose(-4);
chord2.toString(); // -> "Ab/C"
```

### Convert numeric chord to chord symbol

```javascript
const numericChord = parse('2/4');
const chordSymbol = toChordSymbol(numericChord, 'E');
chordSymbol.toString(); // -> "F#m/A"
```

---
_Source: https://npm.io/package/chordjs · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
