Have ideas to improve npm?Join in the discussion! »


    1.1.13 • Public • Published


    Support me on Patreon Buy me a book PayPal Ask me anything Version Downloads Get help on Codementor

    Buy Me A Coffee

    Parses the GitHub contributions calendar SVG code into JSON.

    ☁️ Installation

    # Using npm
    npm install --save github-calendar-parser
    # Using yarn
    yarn add github-calendar-parser

    📋 Example

    const parse = require("github-calendar-parser");
    var svg = `
            <svg width="722" height="112" class="js-calendar-graph-svg">
                <g transform="translate(10, 20)" data-hydro-click="{&quot;event_type&quot;:&quot;user_profile.click&quot;,&quot;payload&quot;:{&quot;profile_user_id&quot;:2864371,&quot;target&quot;:&quot;CONTRIBUTION_CALENDAR_SQUARE&quot;,&quot;user_id&quot;:null,&quot;originating_url&quot;:&quot;https://github.com/users/IonicaBizau/contributions&quot;}}" data-hydro-click-hmac="c29bb84527b62dafc7ab4208ed2db21ea4195839d541da829d109a8d172bee42">
                    <g transform="translate(0, 0)">
                    <rect class="day" width="10" height="10" x="14" y="0" fill="var(--color-calendar-graph-day-bg)" data-count="0" data-date="2019-11-03"/>
                    <rect class="day" width="10" height="10" x="14" y="13" fill="var(--color-calendar-graph-day-bg)" data-count="0" data-date="2019-11-04"/>
                    <rect class="day" width="10" height="10" x="14" y="26" fill="var(--color-calendar-graph-day-bg)" data-count="0" data-date="2019-11-05"/>
                    <rect class="day" width="10" height="10" x="14" y="39" fill="var(--color-calendar-graph-day-bg)" data-count="0" data-date="2019-11-06"/>
                    <rect class="day" width="10" height="10" x="14" y="52" fill="var(--color-calendar-graph-day-bg)" data-count="0" data-date="2019-11-07"/>
                    <rect class="day" width="10" height="10" x="14" y="65" fill="var(--color-calendar-graph-day-bg)" data-count="0" data-date="2019-11-08"/>
                    <rect class="day" width="10" height="10" x="14" y="78" fill="var(--color-calendar-graph-day-bg)" data-count="0" data-date="2019-11-09"/>
                    <g transform="translate(14, 0)">
                        <rect class="day" width="10" height="10" x="13" y="0" fill="var(--color-calendar-graph-day-bg)" data-count="0" data-date="2019-11-10"/>
                        <rect class="day" width="10" height="10" x="13" y="13" fill="var(--color-calendar-graph-day-L1-bg)" data-count="4" data-date="2019-11-11"/>
                        <rect class="day" width="10" height="10" x="13" y="26" fill="var(--color-calendar-graph-day-bg)" data-count="0" data-date="2019-11-12"/>
                        <rect class="day" width="10" height="10" x="13" y="39" fill="var(--color-calendar-graph-day-L1-bg)" data-count="1" data-date="2019-11-13"/>
                        <rect class="day" width="10" height="10" x="13" y="52" fill="var(--color-calendar-graph-day-bg)" data-count="0" data-date="2019-11-14"/>
                        <rect class="day" width="10" height="10" x="13" y="65" fill="var(--color-calendar-graph-day-bg)" data-count="0" data-date="2019-11-15"/>
                        <rect class="day" width="10" height="10" x="13" y="78" fill="var(--color-calendar-graph-day-bg)" data-count="0" data-date="2019-11-16"/>
    // {
    //     "last_year": 5,
    //     "longest_streak": 1,
    //     "longest_streak_range": ["2019-11-11T00:00:00.000Z", "2019-11-11T00:00:00.000Z"],
    //     "current_streak": 0,
    //     "current_streak_range": ["2019-11-16T00:00:00.000Z", "2019-11-13T00:00:00.000Z"],
    //     "weeks": [
    //         [{
    //             "fill": "#eee",
    //             "date": "2019-11-03T00:00:00.000Z",
    //             "count": 0,
    //             "level": 0
    //         },
    //         ...
    //         {
    //             "fill": "#eee",
    //             "date": "2019-11-09T00:00:00.000Z",
    //             "count": 0,
    //             "level": 0
    //         }]
    //     ],
    //     "days": [{
    //         "fill": "#eee",
    //         "date": "2019-11-03T00:00:00.000Z",
    //         "count": 0,
    //         "level": 0
    //     },
    //     ...
    //     {
    //         "fill": "#eee",
    //         "date": "2019-11-16T00:00:00.000Z",
    //         "count": 0,
    //         "level": 0
    //     }],
    //     "last_contributed": "2019-11-13T00:00:00.000Z"
    // }

    Get Help

    There are few ways to get help:

    1. Please post questions on Stack Overflow. You can open issues with questions, as long you add a link to your Stack Overflow question.
    2. For bug reports and feature requests, open issues. 🐛
    3. For direct and quick help, you can use Codementor. 🚀

    📝 Documentation


    Parses the SVG input (as string).


    • String input: The SVG code of the contributions calendar.


    • Object An object containing:
    • last_year (Number): The total contributions in the last year.
    • longest_streak (Number): The longest streak.
    • longest_streak_range (Array): An array of two date objects representing the date range.
    • current_streak (Number): The current streak.
    • current_streak_range (Array): An array of two date objects representing the date range.
    • days (Array): An array of day objects:
      • fill (String): The hex color.
      • date (Date): The day date.
      • count (Number): The number of commits.
      • level (Number): A number between 0 and 4 (inclusive) representing the contribution level (more commits, higher value).
    • weeks (Array): The day objects grouped by weeks (arrays).
    • last_contributed (Date): The last contribution date.

    😋 How to contribute

    Have an idea? Found a bug? See how to contribute.

    💖 Support my projects

    I open-source almost everything I can, and I try to reply to everyone needing help using these projects. Obviously, this takes time. You can integrate and use these projects in your applications for free! You can even change the source code and redistribute (even resell it).

    However, if you get some profit from this or just want to encourage me to continue creating stuff, there are few ways you can do it:

    • Starring and sharing the projects you like 🚀

    • Buy me a book—I love books! I will remember you after years if you buy me one. 😁 📖

    • PayPal—You can make one-time donations via PayPal. I'll probably buy a coffee tea. 🍵

    • Support me on Patreon—Set up a recurring monthly donation and you will get interesting news about what I'm doing (things that I don't share with everyone).

    • Bitcoin—You can send me bitcoins at this address (or scanning the code below): 1P9BRsmazNQcuyTxEqveUsnf5CERdq35V6

    Thanks! ❤️

    💫 Where is this library used?

    If you are using this library in one of your projects, add it in this list.

    • github-calendar
    • react-github-calendar-x
    • @xwl7001/react-github-calendar

    📜 License

    MIT © Ionică Bizău


    npm i github-calendar-parser

    DownloadsWeekly Downloads






    Unpacked Size

    14.1 kB

    Total Files


    Last publish


    • avatar