CSS Minifier for Go

Free online css minifier with Go code examples

Working with css minifier in Go? Our free online css minifier helps Go developers format, validate, and process data instantly. Below you will find Go code examples using github.com/tdewolff/minify so you can achieve the same result programmatically in your own projects.

Try the CSS Minifier Online

Use our free CSS Minifier directly in your browser — no setup required.

Open CSS Minifier

Go Code Example

package main

import (
    "fmt"
    "github.com/tdewolff/minify/v2"
    "github.com/tdewolff/minify/v2/css"
)

func main() {
    m := minify.New()
    m.AddFunc("text/css", css.Minify)

    input := "body { background-color: #ffffff; font-size: 16px; margin: 0; padding: 0; }"
    output, _ := m.String("text/css", input)
    fmt.Println(output)
}

Quick Setup

Library: github.com/tdewolff/minify
go get github.com/tdewolff/minify/v2

Go Tips & Best Practices

  • tdewolff/minify supports CSS, JS, HTML, JSON, SVG, and XML
  • It is one of the fastest minifiers available
  • Use m.AddFunc to register minifiers for each content type

Frequently Asked Questions

CSS Minifier in Other Languages

More Go Tools