# Display SVG

**URL:** <https://discuss.streamlit.io/t/display-svg/172>\
**Category:** Using Streamlit\
**Tags:** tutorial, css\
**Created:** [October 4, 2019, 4:52pm UTC](https://discuss.streamlit.io/t/display-svg/172 "2019-10-04T16:52:48Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![Adrien\_Treuille](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/adrien_treuille/32/8_2.png) [@Adrien\_Treuille](https://discuss.streamlit.io/u/Adrien_Treuille)\
**Post date:** [October 12, 2019, 7:11am UTC](https://discuss.streamlit.io/t/display-svg/172/5 "2019-10-12T07:11:32Z")

</div>

Hi @jeremie:

I believe what you’re looking for is:

```python
def render_svg(svg):
    """Renders the given svg string."""
    b64 = base64.b64encode(svg.encode('utf-8')).decode("utf-8")
    html = r'<img src="data:image/svg+xml;base64,%s"/>' % b64
    st.write(html, unsafe_allow_html=True)

```

You can see an example of it’s use in [this gist](https://gist.github.com/treuille/8b9cbfec270f7cda44c5fc398361b3b1) which you can try out by running:

```bash
streamlit run https://gist.githubusercontent.com/treuille/8b9cbfec270f7cda44c5fc398361b3b1/raw/19ce438121af7907d5d1527e36d715dcef755bd3/render_svg.py

```

Please note that this has only been tested in Python 3.6.

---

_[View the full topic](https://discuss.streamlit.io/t/display-svg/172)._
