Render HTML with JSX
  • OCaml 73.1%
  • Reason 10.6%
  • CSS 6%
  • Raku 4.5%
  • JavaScript 2.8%
  • Other 3%
Find a file
2026-08-17 09:33:51 +00:00
.githooks Fork srr 2023-11-05 00:48:07 +01:00
.github Run benchmarks on stable CI entry 2026-08-05 11:13:59 +00:00
bench Untrack machine-specific benchmark baselines 2026-07-11 16:35:17 +00:00
demo JSX.list wrapping for multiple children 2026-08-04 13:18:11 +00:00
docs JSX.list wrapping for multiple children 2026-08-04 13:18:11 +00:00
htmx Format stuff 2026-04-30 15:17:33 +00:00
lib Remove pretty_expressive dependency 2026-08-06 09:44:42 +00:00
ppx JSX.list wrapping for multiple children 2026-08-04 13:18:11 +00:00
site Remove unused code body border token 2026-08-17 09:33:51 +00:00
test Remove pretty_expressive dependency 2026-08-06 09:44:42 +00:00
.gitattributes Fix png 2024-03-06 16:28:07 +01:00
.gitignore Improve watch mode and remove md from the repo 2026-03-20 17:35:02 +00:00
.ocamlformat Improve docs, by fixing typos and run formatter 2026-03-09 19:18:10 +00:00
AGENTS.md push an agents file 2026-04-30 15:16:59 +00:00
CHANGES.md Prepare 0.1.0 2026-08-04 13:19:52 +00:00
dune Fix ocaml 5.4 setup and remove from opam 2025-12-16 17:49:51 +00:00
dune-project Remove pretty_expressive dependency 2026-08-06 09:44:42 +00:00
html_of_jsx.opam Remove pretty_expressive dependency 2026-08-06 09:44:42 +00:00
LICENSE.md Add mit 2024-02-10 16:46:05 +01:00
Makefile Update to Dune 3.24 2026-08-04 14:58:55 +00:00
README.md Fix links for README and docs 2026-04-13 11:31:38 +00:00

Html_of_jsx logo Html_of_jsx logo

Render HTML with JSX

html_of_jsx is a JSX transformation and a library to write HTML in OCaml, Reason and mlx.

Features

  • Brings the "component model" to HTML
  • Supports all of the Reason's JSX features (uppercase components, fragments, optional attributes, punning)
  • but with a few improvements (lowercase components, no need to add the ppx annotation)
  • No React idioms (no className, no htmlFor, no onChange, etc...)
  • Integrates well with htmx
  • Type-safe, validates attributes and their types (it can be better thought)
  • Works with OCaml, Reason and mlx
  • Minimal core API
    • JSX.render to render a JSX element to an HTML string
    • Helpers to construct nodes: JSX.string, JSX.int, JSX.float, JSX.null, JSX.list, JSX.array, JSX.unsafe
    • Advanced rendering: JSX.render_to_channel, JSX.render_streaming
  • Designed to work on the server, but can be used on the client-side as well (with Melange or jsoo)

Installation

opam install html_of_jsx -y
(libraries html_of_jsx)
(preprocess (pps html_of_jsx.ppx))

Usage

let element: JSX.element = <a href="https://x.com/davesnx">
  <span> {"Click me!"} </span>
</a>;

let html: string = JSX.render(element);
/* <a href="https://x.com/davesnx"><span>Click me!</span></a> */

Check the demo/server.re file to see a full example.

Documentation

Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

Development

# Install dependencies
make install

# Run tests
make test

# Build the project
make build

# Run the demo server
make demo

Credits

This library was extracted from server-reason-react and later simplified to work only with HTML5.

License

MIT © David Sancho