{"id":20299845,"url":"https://github.com/python-ninja-hebi/python-ukulele-chord-to-svg","last_synced_at":"2026-06-07T00:32:29.653Z","repository":{"id":178032484,"uuid":"619210819","full_name":"Python-Ninja-Hebi/python-ukulele-chord-to-svg","owner":"Python-Ninja-Hebi","description":"Creating Ukulele Chord Diagrams in SVG with Python","archived":false,"fork":false,"pushed_at":"2023-03-28T12:00:14.000Z","size":33,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-14T10:33:37.652Z","etag":null,"topics":["python","svg","ukulele","ukulele-chords"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Python-Ninja-Hebi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-03-26T15:39:54.000Z","updated_at":"2023-10-13T09:52:55.000Z","dependencies_parsed_at":null,"dependency_job_id":"41c13d8c-2f0f-4cda-b524-3cbe6dd7ed26","html_url":"https://github.com/Python-Ninja-Hebi/python-ukulele-chord-to-svg","commit_stats":null,"previous_names":["python-ninja-hebi/python-ukulele-chord-to-svg"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Python-Ninja-Hebi%2Fpython-ukulele-chord-to-svg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Python-Ninja-Hebi%2Fpython-ukulele-chord-to-svg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Python-Ninja-Hebi%2Fpython-ukulele-chord-to-svg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Python-Ninja-Hebi%2Fpython-ukulele-chord-to-svg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Python-Ninja-Hebi","download_url":"https://codeload.github.com/Python-Ninja-Hebi/python-ukulele-chord-to-svg/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241795062,"owners_count":20021386,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["python","svg","ukulele","ukulele-chords"],"created_at":"2024-11-14T16:16:31.798Z","updated_at":"2026-06-07T00:32:29.647Z","avatar_url":"https://github.com/Python-Ninja-Hebi.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Creating Ukulele Chord Diagrams in SVG with Python\n\nWith the Python modul __uchord__ you can create ukulele chord diagrams in SVG format.   \n\n\n```python\nimport uchord\n\nuchord.write_chord('c.svg','C','0003')\n```\n\n\u003cimg src=\"pic/c.svg\" align=\"left\"\u003e\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\n\nIf you like it, use it. If you have some suggestions, tell me (gkvoelkl@nelson-games.de).\n\n# Thanks\n\nSpecial thanks to the project https://github.com/pianosnake/uke-chord where I learned much about \nSVG and chord diagrams. I recycled some of the svg commands.\n\n# Installation\n\n* First you need Python 3 (https://www.python.org, ) - Python 3.6 should work, because it's the development environment\n* And this modul uchord - simply copy the source\n\nOr try\n\n\n```python\npip install uchord\n```\n\nThat should work.\n\n# Changelog\n\n|Version       |                                                                                          |\n|--------------|------------------------------------------------------------------------------------------|\n|  0.1.0       | To start with|\n\n# Example\n\nThe ukulele chord diagrams are a picture of the fretboard.\nThe four strings are the vertical lines. The dots are the places where your fingers should be.\n\n\u003cimg src=\"pic/f.svg\" align=\"left\"\u003e\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\n\nFor example the F major chord. You have to put one finger at the __second__ fret of the first string and one at the __first__ fret of the third string. String two and four are empty.\n\n\nThe number *2010* represents the F chord. Every digit stands for a string. This representation is used in *uchord*, too.\n\n\n```python\nimport uchord\n\nuchord.write_chord('f.svg','F','2010')\n```\n\nIf you want to specify which finger should be used for which fret, use the paremeter *fingers*. For an empty string stands the underline.\n\n\n```python\nuchord.write_chord('f.svg','F','2010',fingers='2_1_')\n```\n\n\u003cimg src=\"pic/ff.svg\" align=\"left\"\u003e\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\n\nFor marking the root note or other texts under the chord you can use the parmeter *subtexts*\n\n\n```python\nuchord.write_chord('f.svg','F','2010',fingers='2_1_',subtexts='__R_')\n```\n\n\u003cimg src=\"pic/ffs.svg\" align=\"left\"\u003e\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\n\nIf a chord is played higher up the fret, you can specify the fret to start with. Parameter *starting_fret*\n\n\n```python\nuchord.write_chord('dm7.svg','Dm7','7988',fingers='1423',starting_fret=6)\n```\n\n\u003cimg src=\"pic/dm7.svg\" align=\"left\"\u003e\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\n\n## Using Class Chord and Chords\n\nThe modul *uchord* has the class *Chord* which reprents a specific chord.\n\n\n```python\nfrom uchord import Chord\n\nc = Chord('F','2010',fingers='2_1_',subtexts='__R_')\n```\n\nWith the method *to_svg* you get the svg string\n\n\n```python\nsvg = c.to_svg()\n```\n\nThe class *Chords* stands for a list of chords.\n\n\n```python\nfrom uchord import Chords\n\nc = Chords([Chord(\"F7\",\"2313\",fingers=\"2314\",subtexts=\"__R_\"),\n            Chord(\"C7\",\"0001\",fingers=\"___1\",subtexts=\"_R__\"),\n            Chord(\"G7\",\"0212\",fingers=\"_213\",subtexts=\"R___\"),\n            Chord(\"A7\",\"0100\",fingers=\"_1__\",subtexts=\"___R\")])\nsvg = c.to_svg()\n```\n\n## With IPython and Jupyter\n\nWith *IPython.display* you can use the chords in a notebook.\n\n\n```python\nfrom IPython.display import SVG, display\nfrom uchord import Chords, Chord\n\nc = Chords([Chord(\"F7\",\"2313\",fingers=\"2314\",subtexts=\"__R_\"),\n            Chord(\"C7\",\"0001\",fingers=\"___1\",subtexts=\"_R__\"),\n            Chord(\"G7\",\"0212\",fingers=\"_213\",subtexts=\"R___\"),\n            Chord(\"A7\",\"0100\",fingers=\"_1__\",subtexts=\"___R\")])\n\ndisplay(SVG(c.to_svg()))\n```\n\n\n    \n![svg](output_37_0.svg)\n    \n\n\n\n```python\nwith open('chords.svg', 'w') as f:\n        f.write(c.to_svg())\n```\n\nYou can define your magic command for chords\n\n\n```python\nfrom IPython.core.magic import register_cell_magic\nfrom IPython.display import SVG, display\n\nfrom uchord import Chord, Chords\n\n@register_cell_magic\ndef uchord(line, cell):\n    \n    lines = cell.splitlines()\n    chordlist = []\n    name = \"\" \n    frets = \"\"\n    starting_fret=-1\n    fingers=\"\"\n    subtexts=\"\"\n    \n    for l in lines:\n        tokens = l.split(',')\n\n        name = tokens[0].strip()\n        frets = tokens[1].strip()\n        \n        for t in tokens[2:]:\n            arg = t.split('=')\n            argname = arg[0].strip()\n            if argname.upper() == \"FINGERS\":\n                fingers = arg[1].strip()\n            elif argname.upper() == \"SUBTEXTS\":\n                subtexts = arg[1].strip()\n            elif argname.upper() == \"STARTING_FRET\":\n                starting_fret = int(arg[1])\n                \n        chordlist.append(Chord(name, frets, fingers=fingers, subtexts=subtexts, starting_fret=starting_fret))\n    \n    return display(SVG(Chords(chordlist).to_svg()))\n```\n\nto use\n\n\n```python\n%%uchord\nA7, 0100, fingers=_1__, subtexts=___R\nG7, 0212, fingers=_213, subtexts=R__3\nF7, 2313, fingers=2314, subtexts=__R5\nC7, 0001, fingers=___1, subtexts=_R_7\n```\n\n\n    \n![svg](output_42_0.svg)\n    \n\n\n# Songs\n\n## Bonnie und Clyde\n\nVerse\n\n\n```python\n%%uchord\nG, 0232\nEm7, 0202\nA7sus4, 0200\nCadd9, 0203\n```\n\n\n    \n![svg](output_46_0.svg)\n    \n\n\n\n```python\n%%uchord\nD, 2220\nDsus2, 2200\n```\n\n\n    \n![svg](output_47_0.svg)\n    \n\n\nPre Chorus\n\n\n```python\n%%uchord\nCadd9, 0203\nDadd11, 2230\nEm7, 0202\n```\n\n\n    \n![svg](output_49_0.svg)\n    \n\n\n## II V I\n\n### V\n\n\n```python\n%%uchord\nA7, 0100, fingers=_1__, subtexts=___R\nG7, 0212, fingers=_213, subtexts=R__3\nF7, 2313, fingers=2314, subtexts=__R5\nC7, 0001, fingers=___1, subtexts=_R_7\n```\n\n\n    \n![svg](output_52_0.svg)\n    \n\n\n### II\n\n\n```python\n%%uchord\nAm7, 0000, fingers=____, subtexts=___R\nGm7, 0211, fingers=_211, subtexts=R__3\nFm7, 1313, fingers=2314, subtexts=__R5\nDm7, 2213, fingers=2213, subtexts=_R_7\n```\n\n\n    \n![svg](output_54_0.svg)\n    \n\n\n### I\n\n\n```python\n%%uchord\nAmaj7, 1100, fingers=12__, subtexts=___R\nGmaj7, 0222, fingers=_111, subtexts=R__3\nFmaj7, 1413, fingers=2413, subtexts=__R5\nCmaj7, 0002, fingers=___1, subtexts=_R_7\n```\n\n\n    \n![svg](output_56_0.svg)\n    \n\n\n## II V I G\n\n\n```python\n%%uchord\nG6, 0202, fingers=_2_3, subtexts=R___\nEdim7, 0101, fingers=_2_3\nAm7, 0000, subtexts=7__R\nD7, 2223, fingers=1112, subtexts=_R_7\n```\n\n\n    \n![svg](output_58_0.svg)\n    \n\n\n\n```python\n%%uchord\nG6, 4435, fingers=2213, subtexts=__R_\nEdim7, 3434, fingers=1324, subtexts=_R__\nAm7, 2433, subtexts=R___\nD7, 2223, fingers=1112, subtexts=_R_7\n```\n\n\n    \n![svg](output_59_0.svg)\n    \n\n\n\n```python\n%%uchord\nG6, 7777, fingers=1111, subtexts=_R__\nEdim7, 6767, fingers=1324, subtexts=___R\nAm7, 5757, subtexts=__R_\nD7, 5655, fingers=1211, subtexts=____\n```\n\n\n    \n![svg](output_60_0.svg)\n    \n\n\n## chords\n\n| KEY | 1 | 2m | 3m | 4   | 5 | 5-7 | 6m |\n|:---:|:------------:|:-----------:|:------:|:------:|:------:|:------:|:------:|\n| C |![](chords/c.svg \"\")|![](chords/dm.svg \"\")|![](chords/em.svg \"\")|![](chords/f.svg \"\")|![](chords/g.svg \"\")|![](chords/g7.svg \"\")|![](chords/am.svg \"\")|\n| F |![](chords/f.svg \"\")|![](chords/gm.svg \"\")|![](chords/am.svg \"\")|![](chords/bb.svg \"\")|![](chords/c.svg \"\")|![](chords/c7.svg \"\")|![](chords/dm.svg \"\")|\n| Bb |![](chords/bb.svg \"\")|![](chords/cm.svg \"\")|![](chords/dm.svg \"\")|![](chords/eb.svg \"\")|![](chords/f.svg \"\")|![](chords/f7.svg \"\")|![](chords/gm.svg \"\")|\n| Eb |![](chords/eb.svg \"\")|![](chords/fm.svg \"\")|![](chords/gm.svg \"\")|![](chords/ab.svg \"\")|![](chords/bb.svg \"\")|![](chords/bb7.svg \"\")|![](chords/cm.svg \"\")|\n| E |![](chords/e.svg \"\")|![](chords/fism.svg \"\")|![](chords/gism.svg \"\")|![](chords/a.svg \"\")|![](chords/b.svg \"\")|![](chords/b7.svg \"\")|![](chords/cism.svg \"\")|\n| A |![](chords/a.svg \"\")|![](chords/bm.svg \"\")|![](chords/cism.svg \"\")|![](chords/d.svg \"\")|![](chords/e.svg \"\")|![](chords/e7.svg \"\")|![](chords/fism.svg \"\")|\n| D |![](chords/d.svg \"\")|![](chords/em.svg \"\")|![](chords/fism.svg \"\")|![](chords/g.svg \"\")|![](chords/a.svg \"\")|![](chords/a7.svg \"\")|![](chords/bm.svg \"\")|\n| G |![](chords/g.svg \"\")|![](chords/am.svg \"\")|![](chords/bm.svg \"\")|![](chords/c.svg \"\")|![](chords/d.svg \"\")|![](chords/d7.svg \"\")|![](chords/em.svg \"\")|\n\n\n\n```python\nimport uchord\n\nuchord.write_chord('chords/c.svg','C','0003')\nuchord.write_chord('chords/cm.svg','Cm','0333')\nuchord.write_chord('chords/c7.svg','C7','0001')\nuchord.write_chord('chords/cism.svg','Cism','1102')\nuchord.write_chord('chords/d.svg','D','2220')\nuchord.write_chord('chords/d7.svg','D7','2223')\nuchord.write_chord('chords/dm.svg','Dm','2210')\nuchord.write_chord('chords/eb.svg','Eb','3331')\nuchord.write_chord('chords/e.svg','E','4442')\nuchord.write_chord('chords/e7.svg','E7','1202')\nuchord.write_chord('chords/em.svg','Em','0432')\nuchord.write_chord('chords/f.svg','F','2010')\nuchord.write_chord('chords/fm.svg','Fm','1013')\nuchord.write_chord('chords/f7.svg','F7','2313')\nuchord.write_chord('chords/fism.svg','Fism','2120')\nuchord.write_chord('chords/g.svg','G','0232')\nuchord.write_chord('chords/gm.svg','Gm','0231')\nuchord.write_chord('chords/g7.svg','G7','0212')\nuchord.write_chord('chords/gism.svg','Gism','4342')\nuchord.write_chord('chords/ab.svg','Ab','5343')\nuchord.write_chord('chords/a.svg','A','2100')\nuchord.write_chord('chords/a7.svg','A7','0100')\nuchord.write_chord('chords/am.svg','Am','2000')\nuchord.write_chord('chords/bb.svg','Bb','3211')\nuchord.write_chord('chords/bb7.svg','Bb7','1211')\nuchord.write_chord('chords/b.svg','B','4322')\nuchord.write_chord('chords/bm.svg','Bm','4222')\nuchord.write_chord('chords/b7.svg','B7','2322')\n```\n\n# Source\n\nuke-chord https://github.com/pianosnake/uke-chord\n\nHow to read chord https://ukulele-chords.com/faq/how-to-read-chord\n\n\n```python\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpython-ninja-hebi%2Fpython-ukulele-chord-to-svg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpython-ninja-hebi%2Fpython-ukulele-chord-to-svg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpython-ninja-hebi%2Fpython-ukulele-chord-to-svg/lists"}