# How to render string to html / escape for html

**URL:** <https://discourse.julialang.org/t/how-to-render-string-to-html-escape-for-html/135146>\
**Category:** General Usage\
**Tags:** html\
**Created:** [January 19, 2026, 7:10pm UTC](https://discourse.julialang.org/t/how-to-render-string-to-html-escape-for-html/135146 "2026-01-19T19:10:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jar1](https://avatars.discourse-cdn.com/v4/letter/j/c0e974/32.png) [@jar1](https://discourse.julialang.org/u/jar1)\
**Post date:** [January 19, 2026, 7:10pm UTC](https://discourse.julialang.org/t/how-to-render-string-to-html-escape-for-html/135146/1 "2026-01-19T19:10:43Z")

</div>

How do I render a string into html?

For example `s = "x < y"; render(s)` should become `"x &lt; y"`.

This works but it’s a little verbose:

```julia-auto
using HypertextLiteral
let io = IOBuffer()
    print(io, HypertextLiteral.Result(HypertextLiteral.content(s)))
    seekstart(io)
    read(io, String)
end
"x &lt; y"

```

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [January 19, 2026, 9:55pm UTC](https://discourse.julialang.org/t/how-to-render-string-to-html-escape-for-html/135146/2 "2026-01-19T21:55:40Z")

</div>

Using the standard library:

```julia-auto
using Markdown
s = "x < y"
Markdown.htmlesc(s) # "x &lt; y"

```
