Description #
Hiccup is a Clojure and ClojureScript library that represents HTML and XML using Clojure data structures, typically vectors. It enables dynamic web page generation using purely functional syntax.
History #
Hiccup was introduced in the early 2010s by Jonathan Clouser as part of the Clojure web development ecosystem. It was designed to make HTML generation in functional codebases both readable and composable.
Hello World Code #
[:h1 "Hello, World!"]
How to Run #
Option 1: Online
Try in-browser with Try Clojure:
https://www.tryclj.com/
Option 2: Local
Add to your Clojure project:
[hiccup "1.0.5"]
Example usage:
(require '[hiccup.core :refer [html]])
(html [:h1 "Hello, World!"])
This outputs:
<h1>Hello, World!</h1>
Key Concepts #
- Vector-based HTML representation
- Functional and composable syntax
- Built entirely in Clojure/ClojureScript
- Used in Ring-based web apps (e.g., Compojure, Luminus)
- Auto-escapes content by default
- Great for server-side rendering in Clojure apps
- DSL is just Clojure data — no custom parser
- Can be used to build static pages or dynamic UIs
- Compatible with Hiccup-like rendering in Reagent
- Often paired with backend routing libraries
Try It Online #
Fun Facts #
- Hiccup inspired the data-driven rendering style in many ClojureScript UI libraries.
- Since Hiccup is just Clojure data, you can easily transform and manipulate markup like any other data structure.
- The simplicity of Hiccup made it the default templating choice in many early Clojure web frameworks.
Resources #
Official site
Docs or tutorial
GitHub or interpreter
Community or learning resources