GitPedia

Swim

A DSL for writing HTML in Swift

From robb·Updated June 6, 2026·View on GitHub·

A DSL for building HTML documents with Swift [function builders]. The project is written primarily in Swift, first published in 2019. Key topics include: dsl, html, swift, swift-5.

Latest release: 0.4.00.4.0: Explicit Void
March 21, 2022View Changelog →

Swim – Swift Markup

A DSL for building HTML documents with Swift function builders.

Currently in use on my personal website.

swift
import Swim import HTML let myDocument = html(lang: "en-US") { head { meta(charset: "utf-8", content: "text/html", httpEquiv: "Content-Type") } body(customAttributes: [ "data-foo": "bar" ]) { article(classes: "readme", "modern") { header { h1 { "This is a great article." } } p { "Hello World!" br() "How are you?" } p { "This is a" a(href: "https://swift.org") { "link to the Swift website" } "." } } } }

By generating all words in the language according to the HTML specification, we can make sure that only valid HTML can be expressed.

For example, the above would generate this HTML:

html
<html lang="en-US"> <head> <meta http-equiv="Content-Type" charset="utf-8" content="text/html" /> </head> <body data-foo="bar"> <article class="readme modern"> <header> <h1> This is a great article. </h1> </header> <p> Hello World! <br/> How are you? </p> <p> This is a <a href="https://swift.org"> link to the Swift website </a> . </p> </article> </body> </html>

Contributors

Showing top 3 contributors by commit count.

View all contributors on GitHub →

This article is auto-generated from robb/Swim via the GitHub API.Last fetched: 6/15/2026