Skip to content
Package48 repository health

Sprig

Over 100 template functions for Go's text/template and html/template, covering strings, lists, dicts, dates, math, crypto, and semver comparisons.

Library Govv3.3.04,752 stars MIT License
go get github.com/Masterminds/sprig/v3
View sourceVisit website

Repository health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
Fair
  • Development activity0
  • Maintenance20
  • Community72
  • Maturity60
  • Momentum40

Technical analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
Good
  • Architecture70
  • Code quality78
  • Innovation55
  • Learning curve80

Sprig is a Go library that extends the standard library’s text/template and html/template packages with more than 100 utility functions. Go’s built-in templating language is deliberately minimal, so Sprig fills the gap with string manipulation, list and dict helpers, date formatting, type conversion, math, cryptographic hashing, regular expressions, URL parsing, and semantic version comparison, all callable directly from template pipelines.

The project is widely used as a dependency inside other tools rather than a standalone application: Helm (the Kubernetes package manager) bundles Sprig to power chart templating, and it shows up throughout the Go templating ecosystem wherever text/template needs more expressive power. It is distributed as a single importable package with no external services or configuration required.

Sprig follows a deliberate design philosophy: template functions should never return hard errors when a sensible default can be produced instead, arguments are frequently ordered to support piping ({{ "foo" | repeat 5 }}), and functions are kept purely presentational rather than allowed to fetch or mutate external data. The library ships two major, source-compatible-but-behaviorally-different version lines (v2 and v3), with v3 as the actively maintained release on the module path github.com/Masterminds/sprig/v3.

What You Get

  • A single sprig.FuncMap() call that registers 100+ functions on any text/template or html/template instance
  • String helpers (trim, truncate, case conversion, base64/base32, quoting, wrapping) inspired by Twig and underscore.js
  • List and dict helpers (push, prepend, uniq, without, merge, pluck, dict manipulation) using reflection so they work across slice and map types
  • Date formatting and manipulation functions, plus math, type-conversion, and default-value helpers for safe fallbacks
  • Cryptographic helpers (SHA, bcrypt, derivePassword, genPrivateKey) and URL/regex utilities for common templating chores
  • Semver comparison functions built on Masterminds/semver for version-gated template logic
  • A HermeticTxtFuncMap/HermeticHtmlFuncMap variant that strips non-deterministic functions (like now or randAlphaNum) for reproducible rendering

Common Use Cases

  • Kubernetes/Helm chart templating, where Sprig is the built-in function set for chart authors
  • Generating configuration files, boilerplate code, or infrastructure manifests from Go templates
  • Building internal CLI or codegen tools that render text/HTML from user-supplied or static templates
  • Adding safe default values and type coercion to templates fed by loosely-typed data (YAML/JSON configs)
  • Comparing semantic versions inside templates to gate feature output by version constraints

Under The Hood

Architecture

Sprig is organized as a flat, single-package library with functions grouped by domain into separate files (strings.go, list.go, dict.go, date.go, crypto.go, numeric.go, regex.go, url.go, semver.go, reflect.go, network.go, defaults.go). A central functions.go assembles every domain’s exports into one genericMap, exposed through FuncMap()/TxtFuncMap()/HtmlFuncMap() and hermetic variants that filter out non-deterministic entries like now and random generators via a nonhermeticFunctions list. There is no layering beyond this registry pattern — each function is a small, self-contained transform with no shared internal state, which keeps the blast radius of any single function change limited to its own file.

Tech Stack

The module targets modern Go (go.mod requires go 1.23 with a 1.24 toolchain) and pulls in a small set of focused dependencies: dario.cat/mergo for map merging, Masterminds/goutils and huandu/xstrings for string helpers, Masterminds/semver/v3 for version comparison, google/uuid for identifiers, mitchellh/copystructure for deep copies, shopspring/decimal for precise arithmetic, spf13/cast for type coercion, and golang.org/x/crypto for hashing/bcrypt. There is no build tooling beyond go build/go test; a Makefile wraps common commands and GitHub Actions runs the test suite on push.

Code Quality

Every domain file has a matching _test.go file (crypto, date, dict, list, network, numeric, regex, semver, strings, url, reflect, defaults, flow_control), and tests exercise functions through actual template execution via a runt() helper rather than only unit-testing raw Go calls, which validates the piping behavior end to end. testify/assert is used for assertions. Error handling favors returning zero-value/default output over propagating errors, consistent with the project’s stated design principle that template functions shouldn’t break rendering. No linter config or static-analysis tooling is checked in beyond go vet implied by CI.

What Makes It Unique

Sprig’s contribution isn’t a novel algorithm but a deliberate, well-documented set of conventions for template-function ergonomics: reversed argument order to support piping, refusal to hit external error paths where a default will do, and a hard rule against functions that fetch external data or override core template behavior. Its main technical distinction is being the de facto function set behind Helm’s chart templating, which has made its API surface and defaults an implicit standard across the Go templating ecosystem rather than one library among many.

Used by 15 apps in this directory

Every app whose dependencies include github.com/Masterminds/sprig/v3, nine to a page.

Showing 15 apps
Go 86%Apache 2.0

Argo Workflows

17,108

Data Engineering · Devops

The most popular Kubernetes-native workflow engine for orchestrating containerized DAGs, ML pipelines, CI/CD, and parallel batch jobs at scale.

App
Built with
  • Go 86%
  • TypeScript 10%
Updated todayView details
Go 58%Apache 2.0

Authgear

2,158

Authentication

Open-source, self-hostable authentication platform with passkeys, biometric login, SSO, MFA, and GraphQL admin API — a full Auth0/Clerk/Firebase alternative for SaaS and mobile apps.

App
Built with
  • Go 58%
  • HTML 20%
  • TypeScript 19%
Updated yesterdayView details
Go 99%Apache 2.0

Caddy

79,343

Devops · Security

The only web server that obtains and renews TLS certificates automatically, with HTTP/1-2-3 support and zero dependency on external runtimes.

App
Built with
  • Go 99%
Updated 2 days agoView details
TypeScript 47%AGPL 3.0

Grafana

78,021

Analytics · Monitoring

The open-source observability platform that unifies metrics, logs, and traces from any data source into dynamic, queryable dashboards.

App
Built with
  • TypeScript 47%
  • Go 47%
Updated todayView details
Go 97%Apache 2.0

infracost

12,626

Developer Tools · Devops

Infracost shows cloud cost estimates for Terraform, CloudFormation, and AWS CDK before you deploy — in your terminal, editor, AI coding agent, and pull requests.

App
Built with
  • Go 97%
Updated yesterdayView details
Go 50%AGPL 3.0

listmonk

24,399

Blogging · Marketing

High-performance, self-hosted newsletter and mailing list manager packaged as a single binary with built-in analytics, transactional messaging, and multi-channel delivery.

App
Built with
  • Go 50%
  • JavaScript 22%
  • HTML 21%
Updated 6 days agoView details
Go 48%GPL 3.0

Netdata

81,562

Devops · Monitoring

Real-time per-second metrics, ML-powered anomaly detection, and zero-config observability for any infrastructure.

App
Built with
  • Go 48%
  • C 28%
  • Rust 16%
Updated todayView details
Go 91%Apache 2.0

Ory Kratos

13,962

Authentication

API-first identity and user management that handles login, registration, MFA, and recovery so your application never has to.

App
Built with
  • Go 91%
Updated 3 months agoView details
Go 40%Apache 2.0

Rill

3,007

Analytics · Data Engineering

The fastest BI tool for humans and agents — define metrics, models, and dashboards as code and query them instantly on ClickHouse or DuckDB.

App
Built with
  • Go 40%
  • TypeScript 39%
  • Svelte 19%
Updated yesterdayView details

Join founders building with open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on SubstackJoin 750+ subscribers