npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

chord-shapes

v0.0.3

Published

Generate all playable shapes for any set of notes on any stringed instrument.

Downloads

6

Readme

chord-shapes

Generate all playable shapes for any set of notes on any stringed instrument. This can be useful for:

  • Generating chord diagrams
  • Checking if certains chords are playable in a given instrument
  • Creating alternate tunings
  • Algorithmic composition

Installation

npm i chord-shapes

Usage

import { getShapes } from "chord-shapes";

const pitches = [0, 4, 7]; // C Major triad (C, E, G). Notes are passed as pitch integers
const strings = [4, 9, 14, 19, 23, 28]; // Standard guitar tuning, in pitches
const fretAmount = 18;
const maxFretSpan = 4; // Limits the shape to a playable hand span (e.g., avoids extreme stretches)

const shapes = getShapes(pitches, strings, fretAmount, maxFretSpan);

// OUTPUT
// { frets: [ 'x', 'x', 'x', 0, 1, 0 ], barres: [] }
// { frets: [ 'x', 'x', 'x', 0, 5, 8 ], barres: [] }
// { frets: [ 'x', 'x', 'x', 5, 5, 3 ], barres: [] }
// { frets: [ 'x', 'x', 'x', 5, 8, 0 ], barres: [] }
// { frets: [ 'x', 'x', 'x', 9, 8, 8 ], barres: [] }
// ...

There are usually hundreds of shapes for a set of notes. We can filter or expand the results by passing the following argument to getShapes. The given values are the defaults

const maxIntervalBetweenPitches = 12; // Maximum interval between consecutive pitches.
const fretboardFingers = 5; // How many fingers are available to press frets. Only one finger is required to play a barre.
const doublings = true; // If false, exclude shapes the same pitches doubled at the octave or at the unison.
const bass = null; // If provided, exclude shapes whose lowest pitch-class does not match it. Can be an integer or a list of integers.

Caveats

  • strings are expected to be in ascending order. Output may be wrong otherwise.
  • pitches are converted to pitch-classes before searching for shapes. That means it is not possible to only search for chords that have doublings at the unison or at the octave.
  • The constraint from fretboardFingers may exclude chords playable by strumming. Pass fretboardFingers=Infinity as a workaround.
  • Chords that are only playble by using two barres are excluded from result. Pass fretboardFingers=Infinity as a workaround.
  • Some other constraints that make that may make chords very hard to play or unplayable are not enforced. For instance, for the shape [11,15,14,15,x,x] is listed in the output for pitches=[1,3,4,9] and strings=[4,9,14,19,23,28] //guitar strings even though in some instruments it might be virtually impossible to play due to the body getting in the way.

Test

npm test

Note that the the test suite might take several minutes to run as it runs getShapes for every possible pitch set class once. PRs with improvements to this approach are welcome.

Contribute

PRs are welcome, especially ones that deal with the caveats listed above. Testing the output of getShapes to ensure the chords are actually playable in a real instrument is also of great help.