{
 "kind": "tool",
 "slug": "react-syntax-highlighter",
 "path": "tools/react-syntax-highlighter/",
 "name": "React Syntax Highlighter",
 "maker": null,
 "density": "profile",
 "crumbs": [
  [
   "Tools",
   "tools/"
  ],
  [
   "Markdown, editors and content",
   "tools/content-editors/"
  ]
 ],
 "lead": "React component for syntax highlighting code with Prism.js or Highlight.js.",
 "chips": [
  {
   "label": "Markdown, editors and content",
   "path": "tools/content-editors/"
  },
  {
   "label": "NPM"
  }
 ],
 "primary": {
  "label": "Copy install command",
  "copy": "npm install react-syntax-highlighter"
 },
 "links": [
  {
   "label": "GitHub",
   "href": "https://github.com/react-syntax-highlighter/react-syntax-highlighter"
  },
  {
   "label": "Website",
   "href": "https://github.com/react-syntax-highlighter/react-syntax-highlighter#readme"
  }
 ],
 "track": "New versions, deprecation and license changes on your dashboard",
 "verdicts": [
  {
   "key": "license",
   "label": "License",
   "value": "MIT",
   "status": "yes",
   "sub": "Use it in paid apps",
   "quote": null,
   "note": "License from npm.",
   "src": "https://github.com/react-syntax-highlighter/react-syntax-highlighter"
  },
  {
   "key": "maint",
   "label": "Maintained",
   "value": "Maintained",
   "status": "yes",
   "sub": "Last change Oct 8, 2026",
   "note": "Latest GitHub release Oct 8, 2026. ",
   "src": "https://github.com/react-syntax-highlighter/react-syntax-highlighter"
  },
  {
   "key": "pop",
   "label": "Used by agents' projects",
   "value": "45 projects",
   "status": "info",
   "sub": "#18 of 149 in its category",
   "note": "Dependency in 45 public GitHub projects set up for AI coding agents that we scanned (0.7%).",
   "src": null
  },
  {
   "key": "agent",
   "label": "Agent access",
   "value": "Install only",
   "status": "info",
   "sub": null,
   "note": "Agent skills for this library in the skills catalog; community skills are written by others, read them before you install.",
   "src": null
  }
 ],
 "vfoot": "From the package registry and GitHub, checked daily.",
 "blocks": [
  {
   "id": "overview",
   "nav": "Overview",
   "h2": "What React Syntax Highlighter does",
   "parts": [
    {
     "t": "prose",
     "text": "React Syntax Highlighter builds React elements from a highlight.js or Prism syntax tree instead of injecting an HTML string, and ships its themes as JavaScript style objects so a page needs no stylesheet tag."
    }
   ]
  },
  {
   "id": "popularity",
   "nav": "Popularity",
   "h2": "React Syntax Highlighter popularity",
   "parts": [
    {
     "t": "stats",
     "items": [
      {
       "n": "65",
       "of": "/ 100",
       "l": "Gid Score, #664 overall"
      },
      {
       "n": "9.9M",
       "l": "downloads a week, npm"
      },
      {
       "n": "4,675",
       "l": "GitHub stars"
      },
      {
       "n": "45",
       "l": "agent projects use it"
      }
     ]
    },
    {
     "t": "small",
     "text": "Gid Score measures public popularity and activity, not quality.",
     "link": "How the Gid Score is calculated",
     "path": "tools/top/"
    }
   ]
  },
  {
   "id": "usage",
   "nav": "How it is used",
   "h2": "How React Syntax Highlighter is used",
   "parts": [
    {
     "t": "list",
     "items": [
      "React Syntax Highlighter is a dependency in 45 of the 6,258 public GitHub projects set up for AI coding agents that we scanned (0.9% of the 4,867 JavaScript/TypeScript ones), #18 of 149 in markdown, editors and content.",
      "Counting the projects our scan samples by dependency (Solana 3,067, Ethereum and EVM 1,774, 3D and games 3,130, agent frameworks and SDKs 13,750), it appears in 292; those are left out of every share on this page.",
      "The most used alternative in our scan is Shiki (85 projects).",
      "Projects that use it most often also use clsx (93.3%), Lucide React (93.3%), Tailwind Merge (93.3%)."
     ]
    },
    {
     "t": "h3",
     "text": "By coding agent"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "30 projects, 1.2%",
       "v": "Cursor",
       "path": "agents/cursor/"
      },
      {
       "l": "27 projects, 0.8%",
       "v": "Claude Code",
       "path": "agents/claude-code/"
      },
      {
       "l": "25 projects, 0.8%",
       "v": "GitHub Copilot",
       "path": "agents/github-copilot/"
      },
      {
       "l": "8 projects, 1.7%",
       "v": "Gemini CLI",
       "path": "agents/gemini-cli/"
      },
      {
       "l": "7 projects, 2.5%",
       "v": "Devin Desktop",
       "path": "agents/devin-desktop/"
      }
     ]
    },
    {
     "t": "h3",
     "text": "Often used with"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "In 93.3% of its projects",
       "v": "clsx",
       "path": "tools/clsx/"
      },
      {
       "l": "In 93.3% of its projects",
       "v": "Lucide React",
       "path": "tools/lucide-react/"
      },
      {
       "l": "In 93.3% of its projects",
       "v": "Tailwind Merge",
       "path": "tools/tailwind-merge/"
      },
      {
       "l": "In 86.7% of its projects",
       "v": "Class Variance Authority",
       "path": "tools/class-variance-authority/"
      },
      {
       "l": "In 80.0% of its projects",
       "v": "Next.js",
       "path": "tools/next/"
      },
      {
       "l": "In 77.8% of its projects",
       "v": "Radix UI",
       "path": "tools/radix-ui/"
      },
      {
       "l": "In 100.0% of its projects",
       "v": "React",
       "path": "tools/react/"
      },
      {
       "l": "In 97.8% of its projects",
       "v": "Tailwind CSS",
       "path": "tools/tailwindcss/"
      }
     ]
    }
   ]
  },
  {
   "id": "profile",
   "nav": "Profile",
   "h2": "React Syntax Highlighter in practice",
   "parts": [
    {
     "t": "h3",
     "text": "Strengths"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "Renders a syntax tree, not an HTML string",
       "v": "The maintainer writes that the component builds the virtual DOM from a syntax tree. This allows \"updating only the changing DOM instead of completely overwriting it on any change\" and the use of pure function components."
      },
      {
       "l": "Themes without a stylesheet tag",
       "v": "Styles are JavaScript objects passed as a prop. The README says all styles supported by highlight.js have been ported. To use highlight.js CSS files instead, set <code>useInlineStyles</code> to <code>false</code> and the component adds classNames."
      },
      {
       "l": "A Prism engine for JSX",
       "v": "Importing <code>Prism</code> switches to refractor, which uses Prism.js language definitions. The README says this is beneficial \"especially when highlighting jsx, a problem long unsolved by this module.\""
      },
      {
       "l": "Per-line props",
       "v": "With <code>wrapLines</code> on, each line gets its own span. <code>lineProps</code> passes props to that span as an object or as a function of the line number. The README links a diff demo to show what <code>wrapLines</code> enables."
      }
     ]
    },
    {
     "t": "h3",
     "text": "Watch out for"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "Default import is heavy; light build is manual",
       "v": "The README warns that the standard import \"can have a fairly large footprint\". The light builds are the alternative, but you import and register every language yourself and pass a style."
      },
      {
       "l": "Async build shows plain code first",
       "v": "<code>PrismAsyncLight</code> and <code>LightAsync</code> need a bundler that supports dynamic import. While the chunks load, code appears with line numbers but without highlighting."
      },
      {
       "l": "Types are a separate install",
       "v": "TypeScript users add <code>@types/react-syntax-highlighter</code> as well. The README recommends it to prevent TypeScript or ESLint errors."
      }
     ]
    },
    {
     "t": "h3",
     "text": "Highlight a snippet with a highlight.js theme"
    },
    {
     "t": "tabs",
     "label": "Example",
     "items": [
      {
       "tab": "Jsx",
       "code": "import SyntaxHighlighter from 'react-syntax-highlighter';\nimport { docco } from 'react-syntax-highlighter/dist/esm/styles/hljs';\nconst Component = () => {\n  const codeString = '(num) => num + 1';\n  return (\n    <SyntaxHighlighter language=\"javascript\" style={docco}>\n      {codeString}\n    </SyntaxHighlighter>\n  );\n};"
      }
     ]
    }
   ]
  },
  {
   "id": "more",
   "nav": null,
   "spy_as": "profile",
   "h2": "More about React Syntax Highlighter",
   "parts": [
    {
     "t": "more",
     "items": [
      {
       "title": "Funding",
       "path": "tools/funding/",
       "items": [
        "GitHub Sponsors: https://github.com/conorhastings",
        "1 GitHub sponsors"
       ]
      },
      {
       "title": "Packages around it",
       "items": [
        "tailwind-merge: Tailwind class merging",
        "clsx: className joining",
        "class-variance-authority: component variants",
        "lucide-react: icons",
        "@radix-ui: UI primitives",
        "tailwindcss: utility CSS"
       ]
      },
      {
       "title": "More in Markdown, editors and content",
       "path": "tools/content-editors/",
       "items": [
        {
         "text": "react-markdown",
         "path": "tools/react-markdown/"
        },
        {
         "text": "remark-gfm",
         "path": "tools/remark-gfm/"
        },
        {
         "text": "Marked",
         "path": "tools/marked/"
        },
        {
         "text": "Jinja2",
         "path": "tools/jinja2/"
        },
        {
         "text": "gray-matter",
         "path": "tools/gray-matter/"
        },
        {
         "text": "Tiptap",
         "path": "tools/tiptap/"
        },
        {
         "text": "markdown-it",
         "path": "tools/markdown-it/"
        },
        {
         "text": "MDX",
         "path": "tools/mdx-js/"
        }
       ]
      }
     ]
    }
   ]
  },
  {
   "id": "alternatives",
   "nav": "Alternatives",
   "h2": "Alternatives",
   "parts": [
    {
     "t": "alts",
     "items": [
      {
       "name": "React Syntax Highlighter",
       "me": true,
       "facts": [
        "MIT",
        "Gid 65",
        "9.9M/wk"
       ]
      },
      {
       "name": "Shiki",
       "why": "Beautiful syntax highlighter powered by TextMate grammars with superior accuracy.",
       "path": "tools/shiki/",
       "facts": [
        "MIT",
        "Gid 76",
        "42.6M/wk"
       ]
      },
      {
       "name": "highlight.js",
       "why": "Syntax highlighting library with automatic language detection for code blocks.",
       "path": "tools/highlight-js/",
       "facts": [
        "BSD-3-Clause",
        "Gid 77",
        "58.1M/wk"
       ]
      }
     ],
     "more": "Compare React Syntax Highlighter with another tool",
     "more_path": "tools/compare/"
    }
   ]
  },
  {
   "id": "start",
   "nav": "Get started",
   "h2": "Get started",
   "parts": [
    {
     "t": "install",
     "intro": "Install it.",
     "code": "npm install react-syntax-highlighter"
    },
    {
     "t": "h3",
     "text": "Rules for your agent"
    },
    {
     "t": "rules",
     "label": "Paste into AGENTS.md or CLAUDE.md",
     "text": "## React Syntax Highlighter\n- Take the `style` object from `react-syntax-highlighter/dist/esm/styles/hljs` or `.../styles/prism` to match the import in use, as the README's examples pair them.\n- For JSX code, use the `Prism` or `PrismLight` export.\n- With `Light` or `PrismLight`, call `SyntaxHighlighter.registerLanguage(name, lang)` for every language and always pass a `style`; the light builds provide no default style.\n- Use `PrismAsyncLight` or `LightAsync` only with a bundler that supports dynamic import, and expect unhighlighted code while chunks load.\n- Set `wrapLines` to true when using `lineProps`; `showInlineLineNumbers` has no effect unless `showLineNumbers` is on.\n- To style with highlight.js CSS files, pass `useInlineStyles={false}` so the component appends classNames instead of style objects.\n- In TypeScript projects, add `@types/react-syntax-highlighter` as a dev dependency.\n"
    }
   ]
  }
 ],
 "glance": [
  [
   "Package",
   "npm react-syntax-highlighter"
  ],
  [
   "Category",
   "Markdown, editors and content"
  ],
  [
   "License",
   "MIT"
  ],
  [
   "Latest version",
   "v16.1.2, October 8, 2026"
  ],
  [
   "On GitHub since",
   "January 2016"
  ],
  [
   "Gid Score",
   "65.2"
  ],
  [
   "Rank in category",
   "#18 of 149"
  ],
  [
   "GitHub",
   "react-syntax-highlighter/react-syntax-highlighter"
  ],
  [
   "Last change",
   "Oct 8, 2026"
  ]
 ],
 "good": [
  "Used by mdx-deck, codecrumbs, Spectacle Editor, Superset, as listed by the source; we have not checked each one."
 ],
 "checked_line": "From the package registry, GitHub and our scan of public agent projects; numbers update daily.",
 "logo": "https://agentgid.com/media/avatars/react-syntax-highlighter.png"
}