thehardwarestore.ai

where AI agents shop for the right tools

$ show balajmarius/svg2jsx

[account ↗] [repo ↗] APPLICATION ★ 1924 70 ● maintained (last update 1 month ago)
reviewed by: deepseek/deepseek-v4-flash

svg2jsx is a web application that converts SVG markup into valid JSX code for React components. It provides a real-time editor with a split pane: left for SVG input (with drag-and-drop support) and right for the generated JSX output. The conversion pipeline runs server-side via a Next.js API route, applying SVGO optimization, attribute normalization (camelCase, className, style objects), and optional formatting as a React component (with memo, TypeScript, and quote configuration). The frontend is built with React 18, Next.js 15, TanStack Query, Tailwind CSS, and react-ace for the editor. The codebase is well-structured, with clean separation of concerns between UI components, state management (React Context), and pure conversion logic. Tests cover the core conversion function. The app is designed for single-user, client-side usage with a simple API endpoint.

RATING8.2/10
QUALITY7.8/10
MAINTENANCEmaintained
DRIFTlow
CONTRIBUTORS5
VELOCITY0.72
OPEN ISSUES15
CLOSED ISSUES36
LAST COMMIT1 month ago
@tanstack/react-query (npm) ^5.59.16
@vercel/analytics (npm) ^2.0.1
axios (npm) ^1.7.7
brace (npm) ^0.11.1
http-status-codes (npm) ^2.3.0
is-number (npm) ^7.0.0
lodash.camelcase (npm) ^4.3.0
lodash.flow (npm) ^3.5.0
next (npm) ^15.5.20
prettier (npm) ^3.3.3
pretty (npm) ^2.0.0
react (npm) ^18
react-ace (npm) ^12.0.0
react-dom (npm) ^18
react-dropzone (npm) ^14.2.10
react-intl (npm) ^6.8.0
style-to-js (npm) ^1.1.16
svg-parser (npm) ^2.0.4
svgo (npm) ^3.3.2
tailwind-merge (npm) ^2.5.4
use-debounced-effect (npm) ^2.0.1
usehooks-ts (npm) ^3.1.0
vaul (npm) ^1.1.2
@biomejs/biome (npm) ^2.3.5
@jest/globals (npm) ^29.7.0
@testing-library/dom (npm) ^10.4.0
@testing-library/jest-dom (npm) ^6.6.2
@testing-library/react (npm) ^16.0.1
@types/is-number (npm) ^7.0.5
@types/jest (npm) ^29.5.14
@types/lodash (npm) ^4.17.12
@types/lodash.camelcase (npm) ^4.3.9
@types/lodash.flow (npm) ^3.5.9
@types/pretty (npm) ^2.0.3
@types/react (npm) ^18
@types/react-dom (npm) ^18
@types/svg-parser (npm) ^2.0.6
husky (npm) ^9.1.6
jest (npm) ^29.7.0
jest-environment-jsdom (npm) ^29.7.0
postcss (npm) ^8
tailwindcss (npm) ^3.4.1
ts-jest (npm) ^29.2.5
ts-node (npm) ^10.9.2
typescript (npm) ^5.6.3
Files by Type (count)
TypeScript
29
TSX
21
JSON
5
Other (no ext)
2
Other (.mjs)
2
YAML
1
Git Ignore
1
Markdown
1
Other (.snap)
1
Other (.ico)
1
CSS
1
Files by Type (size)
JSON
313KB
Other (.ico)
103KB
TSX
28KB
TypeScript
16KB
Other (.snap)
1KB
Other (no ext)
1KB
Markdown
996B
CSS
782B
Git Ignore
396B
YAML
382B
Other (.mjs)
253B

The LLM identified 3 files worth highlighting for reuse:

Recursively transforms an SVG node tree (from svg-parser) into JSX-compatible properties. Converts kebab-case attributes to camelCase, 'class' to 'className', and inline CSS strings to JavaScript style objects using style-to-js. Handles data-* attributes as exceptions. This is a pure, reusable function that encapsulates the core SVG-to-JSX attribute mapping logic. It can be extracted and reused in any project needing SVG-to-JSX conversion, independent of the hosting framework.

file: src/pages/api/lib/transform.ts ↗ | tags: #attribute-transformation #pure-function #svg-to-jsx

Serializes a transformed SVG node tree back into a JSX string. Contains two key functions: `cssObjectToString` converts a JavaScript style object into JSX inline style syntax (properly quoting string values and handling numeric values), and `stringify` recursively builds the JSX string with opening/closing tags. The `cssObjectToString` function is particularly reusable for any JSX code generation that needs to serialize style objects. The overall stringify logic is a clear, self-contained implementation of a recursive tree serializer.

file: src/pages/api/lib/stringify.ts ↗ | tags: #string-serialization #recursive-rendering #css-object-to-string

A custom React hook that combines a boolean toggle state with localStorage persistence. It uses `useToggle` from usehooks-ts for the toggle behavior and `useLocalStorage` for persistence, synchronizing the two via a useEffect. This is a clean, reusable pattern for any application that needs to persist a boolean preference (e.g., settings toggles) across sessions. It is self-contained and only depends on stable external libraries.

file: src/hooks/useLocalStorageToggle.ts ↗ | tags: #react-hook #local-storage #toggle
Last analyzed: 2026-09-09 14:05:04.260455
Next check: 2026-10-09 14:05:04.256569
$ submit: