Skip to content
Agents tracked: 440 Downloads (7d): 202M down 19.5% GitHub stars: 10.4M Releases (7d): 607 Agent status: 1 with issuesSince last limit reset: Claude 28d · Codex 0d Updated Oct 21, 2026

React Syntax Highlighter Examples You Can Edit and Run

5 small React Syntax Highlighter examples written by AgentGid from the official docs, one feature each. Every one runs in your browser: change the code and see the result at once, or describe a change and let AI rewrite it. The screenshots are taken from the same code by our server, which also checks that each example starts without errors.

React Syntax Highlighter: usage and stats 45 AI-built projects use it

Try them all in one place

import { useState } from 'react';
import SyntaxHighlighter from 'react-syntax-highlighter';

const samples = {
  javascript: `const total = (items) =>\n  items.reduce((sum, i) => sum + i.price, 0);\n\nconsole.log(total([{ price: 4 }, { price: 6 }])); // 10`,
  python: `def total(items):\n    return sum(i["price"] for i in items)\n\nprint(total([{"price": 4}, {"price": 6}]))  # 10`,
  json: `{\n  "name": "demo",\n  "version": "1.0.0",\n  "private": true\n}`,
};

const btn = (active) => ({
  padding: '6px 12px', borderRadius: 6, border: 'none', cursor: 'pointer',
  background: active ? '#2563eb' : '#2a2a2a', color: '#fff', font: '13px system-ui',
});

export default function App() {
  const [lang, setLang] = useState('javascript');
  return (
    <div style={{ background: '#111', height: 360, padding: 20, boxSizing: 'border-box',
      font: '13px system-ui', color: '#bbb' }}>
      <div style={{ display: 'flex', gap: 8, marginBottom: 12 }}>
        {Object.keys(samples).map((l) => (
          <button key={l} style={btn(l === lang)} onClick={() => setLang(l)}>{l}</button>
        ))}
      </div>
      <SyntaxHighlighter language={lang} customStyle={{ borderRadius: 8, padding: 16, fontSize: 14 }}>
        {samples[lang]}
      </SyntaxHighlighter>
      <p>{SyntaxHighlighter.supportedLanguages.length} languages available in this build</p>
    </div>
  );
}
Ctrl/⌘ + Enter runs

Free for signed-in members, with a daily limit. Describe the change in plain words; the new code runs only in your browser.

Click a language button to re-highlight a different snippet. Code written by AgentGid [1]. How it works, with a screenshot →

Checked Oct 12, 2026: each example starts without errors in Chromium with react-syntax-highlighter 16.1.2, react 19.3.0, react-dom 19.3.0. Needs WebGL.

Sources

  1. React Syntax Highlighter README (GitHub)

Explanations written by AgentGid from the official docs; the numbers in brackets point here. The code marked "written by AgentGid" is ours and free to copy.

Building something with React Syntax Highlighter? Ask AgentGid →