Skip to main content

SVG to PNG converter

Route: /svg-converter (src/app/svg-converter/page.tsx).

In plain terms: users paste or upload SVG; conversion runs in the browser via @lib/services/svg-conversion. The same service backs POST /api/svg-to-png for JSON/binary integrations.

Page layout​

Client page wrapped in ToolsCopyProvider (i18n tool strings from tools catalog).

ComponentRole
SvgConverterInterfaceFile upload (.svg only, max 10MB) or textarea paste; scale/quality/background options
ConversionDisplayCurrent result preview + download
ConversionHistoryLast 10 conversions in session state (not persisted server-side)

SvgConverterInterface calls createSvgToPngConverter({ enableSecurityValidation: true }) and convertWithProgress for UI progress steps — no fetch('/api/svg-to-png') on the default path.

HTTP API​

Co-located reference: svg-to-png route doc.

GET /api/svg-to-png​

Health/capabilities JSON: maxBatchSize: 10, maxSvgSize: '10MB', securityValidation: true, plus converter.getStatus().

POST /api/svg-to-png​

  • Requires Content-Type: application/json.
  • Single body: { svgContent, options?, filename?, format?: 'json' | 'binary' }
    • Validates with converter.validateSvg; failures → 400 INVALID_SVG + safetyIssues.
    • format=binary → image/png with optional Content-Disposition.
    • Default JSON → base64 pngData + dimensions/metadata.
  • Batch body: top-level conversions array (max 10 entries) → parallel convertBatch; summary counts in response.
  • Default converter options in route: quality: 1, scale: 1, timeout: 30000, security validation on.

Error codes (representative)​

CodeHTTPMeaning
INVALID_CONTENT_TYPE400Not JSON
MISSING_SVG_CONTENT400Empty svgContent
BATCH_SIZE_EXCEEDED400More than 10 conversions
CONVERSION_FAILED500Rasterization error

Security​

SVG passes security validation in both client and API paths (enableSecurityValidation: true). Do not disable for operator convenience — malicious SVG can embed scripts or external fetches.


Sources: src/app/svg-converter/page.tsx, src/app/svg-converter/components/SvgConverterInterface.tsx, src/app/api/svg-to-png/route.ts, @lib/services/svg-conversion