PHPackages                             decmuc/svgsanitizer - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Security](/categories/security)
4. /
5. decmuc/svgsanitizer

ActiveLibrary[Security](/categories/security)

decmuc/svgsanitizer
===================

A lightweight PHP library to validate and block unsafe SVG content, preventing XSS and code injection.

v1.1.1(11mo ago)08MITPHPPHP &gt;=7.4CI passing

Since May 24Pushed 10mo agoCompare

[ Source](https://github.com/decMuc/SvgSanitizer)[ Packagist](https://packagist.org/packages/decmuc/svgsanitizer)[ RSS](/packages/decmuc-svgsanitizer/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (1)Versions (4)Used By (0)

SvgSanitizer
============

[](#svgsanitizer)

[![PHP](https://camo.githubusercontent.com/d08ccd35c79d52d5bc06e23fda23ae42616c2fc5169119b335588083eac6bcad/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d2533453d372e342d626c7565)](https://camo.githubusercontent.com/d08ccd35c79d52d5bc06e23fda23ae42616c2fc5169119b335588083eac6bcad/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d2533453d372e342d626c7565) [![License: MIT](https://camo.githubusercontent.com/fdf2982b9f5d7489dcf44570e714e3a15fce6253e0cc6b5aa61a075aac2ff71b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667)](https://camo.githubusercontent.com/fdf2982b9f5d7489dcf44570e714e3a15fce6253e0cc6b5aa61a075aac2ff71b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667)

**SvgSanitizer** is a lightweight PHP library that validates SVG files or fragments and blocks potentially harmful code like JavaScript, embedded objects, inline event handlers, or suspicious Base64 payloads. It helps protect your application from XSS and injection attacks via SVG uploads.

---

**SvgSanitizer** ist eine kompakte PHP-Bibliothek zur Prüfung von SVG-Dateien oder -Inhalten. Sie erkennt und blockiert potenziell schadhaften Code wie JavaScript, eingebettete Objekte, Inline-Handler oder verdächtige Base64-Payloads. Damit schützt sie deine Anwendung vor XSS- oder Injektionsangriffen durch manipulierte SVGs.

---

📦 Installation
--------------

[](#-installation)

### English

[](#english)

Use Composer to add the package:

```
composer require decMuc/SvgSanitizer
```

### Deutsch

[](#deutsch)

Füge die Bibliothek über Composer hinzu:

```
composer require decMuc/SvgSanitizer
```

⚙️ Autoloading
--------------

[](#️-autoloading)

### English

[](#english-1)

Make sure Composer's autoload is enabled:

### Deutsch

[](#deutsch-1)

Stelle sicher, dass Composer's Autoload aktiviert ist:`

```
require_once 'vendor/autoload.php';
```

🚀 Usage / Nutzung
-----------------

[](#-usage--nutzung)

### English

[](#english-2)

Use the `SvgSanitizer` class to check if an SVG is safe. Example:

### Deutsch

[](#deutsch-2)

Verwende die Klasse `SvgSanitizer`, um zu prüfen, ob ein SVG sicher ist. Beispiel:

```
