Project

peasy-css

0.0
A long-lived project that still receives updates
CSS code generator for Ruby — create linear/radial gradients, box/text shadows, border-radius, flexbox layouts, and CSS grid. Zero dependencies, outputs copy-paste CSS.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies
 Project Readme

peasy-css

Gem Version License: MIT GitHub stars

Ruby client for the PeasyCSS API -- minify, beautify, and convert CSS units with tools for gradient generation, shadow creation, flexbox layouts, and grid systems. Zero dependencies beyond Ruby stdlib (Net::HTTP, JSON, URI).

Built from PeasyCSS, a comprehensive CSS toolkit offering free online tools for minifying, formatting, analyzing, and generating CSS code with detailed property guides, layout references, and a glossary covering modern CSS specifications including Grid, Flexbox, Custom Properties, and Container Queries.

Try the interactive tools at peasycss.com -- CSS Minify, CSS Beautify, CSS Unit Converter, and more.

peasy-css demo -- CSS minify, beautify, and unit conversion tools in Ruby terminal

Table of Contents

  • Install
  • Quick Start
  • What You Can Do
    • CSS Optimization Tools
    • Browse CSS Reference Content
    • Search and Discovery
  • API Client
    • Available Methods
  • Learn More About CSS Tools
  • Also Available
  • Peasy Developer Tools
  • License

Install

gem install peasy-css

Or add to your Gemfile:

gem "peasy-css"

Quick Start

require "peasy_css"

client = PeasyCSS::Client.new

# List available CSS tools
tools = client.list_tools
tools["results"].each do |tool|
  puts "#{tool["name"]}: #{tool["description"]}"
end

What You Can Do

CSS Optimization Tools

CSS optimization is essential for web performance. Minified CSS reduces file sizes by removing whitespace, comments, and redundant declarations, while beautified CSS restores readability for debugging. The PeasyCSS API provides programmatic access to these transformations alongside unit conversion tools for responsive design workflows.

Tool Description Use Case
CSS Minify Remove whitespace and comments from CSS Production builds, CI/CD pipelines
CSS Beautify Format and indent CSS for readability Code review, debugging
CSS Unit Converter Convert between px, rem, em, vw, vh Responsive design systems
require "peasy_css"

client = PeasyCSS::Client.new

# Fetch the CSS Minify tool details
tool = client.get_tool("css-minify")
puts "Tool: #{tool["name"]}"           # CSS minification tool
puts "Category: #{tool["category"]}"   # CSS optimization category

# List all CSS file formats and their MIME types
formats = client.list_formats
formats["results"].each do |fmt|
  puts "#{fmt["name"]} (#{fmt["extension"]}): #{fmt["mime_type"]}"
end

Learn more: CSS Minify Tool · CSS Beautify Tool · How to Minify CSS for Production

Browse CSS Reference Content

Modern CSS has evolved far beyond simple selectors and properties. Concepts like CSS Grid, Flexbox, Custom Properties (CSS variables), specificity rules, and the cascade determine how styles are applied. The PeasyCSS glossary provides clear definitions and practical examples for these foundational concepts, while guides offer in-depth tutorials on layout techniques and optimization strategies.

Glossary Term Description
Flexbox One-dimensional layout model for distributing space along a row or column
Grid Two-dimensional layout system for rows and columns simultaneously
Specificity Algorithm that determines which CSS rule takes precedence
Custom Property CSS variables defined with -- prefix, enabling dynamic theming
Minification Process of removing unnecessary characters from CSS without changing functionality
# Browse CSS glossary terms programmatically
glossary = client.list_glossary(search: "flexbox")
glossary["results"].each do |term|
  puts "#{term["term"]}: #{term["definition"]}" # Flexbox layout definition
end

# Read in-depth CSS guides on layout and optimization
guides = client.list_guides(category: "layout")
guides["results"].each do |guide|
  puts "#{guide["title"]} (#{guide["audience_level"]})" # Guide title and difficulty
end

Learn more: Flexbox Glossary · Grid Glossary · CSS Grid vs Flexbox Guide

Search and Discovery

The unified search endpoint queries across all CSS tools, glossary terms, guides, and file formats simultaneously. This is useful for building editor plugins, documentation search, or scripts that need to surface relevant CSS content based on user queries.

# Search across all CSS tools, glossary, and guides
results = client.search("gradient generator")
puts "Found #{results["results"]["tools"].length} tools"
puts "Found #{results["results"]["glossary"].length} glossary terms"

Learn more: Specificity Glossary · Custom Property Glossary · All CSS Guides

API Client

The client wraps the PeasyCSS REST API using only Ruby standard library -- no external dependencies.

require "peasy_css"

client = PeasyCSS::Client.new
# Or with a custom base URL:
# client = PeasyCSS::Client.new(base_url: "https://custom.example.com")

# List tools with pagination and filters
tools = client.list_tools(page: 1, limit: 10, search: "minify")

# Get a specific tool by slug
tool = client.get_tool("css-minify")
puts "#{tool["name"]}: #{tool["description"]}"

# Search across all content
results = client.search("minify")
puts "Found #{results["results"]["tools"].length} tools"

# Browse the glossary
glossary = client.list_glossary(search: "flexbox")
glossary["results"].each do |term|
  puts "#{term["term"]}: #{term["definition"]}"
end

# Discover guides
guides = client.list_guides(category: "css")
guides["results"].each do |guide|
  puts "#{guide["title"]} (#{guide["audience_level"]})"
end

# List file format conversions
conversions = client.list_conversions(source: "css")

# Get format details
format = client.get_format("css")
puts "#{format["name"]} (#{format["extension"]}): #{format["mime_type"]}"

Available Methods

Method Description
list_tools List tools (paginated, filterable)
get_tool(slug) Get tool by slug
list_categories List tool categories
list_formats List file formats
get_format(slug) Get format by slug
list_conversions List format conversions
list_glossary List glossary terms
get_glossary_term(slug) Get glossary term
list_guides List guides
get_guide(slug) Get guide by slug
list_use_cases List use cases
search(query) Search across all content
list_sites List Peasy sites
openapi_spec Get OpenAPI specification

All list methods accept keyword arguments: page:, limit:, category:, search:.

Full API documentation at peasycss.com/developers/. OpenAPI 3.1.0 spec: peasycss.com/api/openapi.json.

Learn More About CSS Tools

Also Available

Language Package Install
Python peasy-css pip install "peasy-css[all]"
TypeScript peasy-css npm install peasy-css
Go peasy-css-go go get github.com/peasytools/peasy-css-go
Rust peasy-css cargo add peasy-css

Peasy Developer Tools

Part of the Peasy Tools open-source developer ecosystem.

Package PyPI npm RubyGems Description
peasy-pdf PyPI npm Gem PDF merge, split, rotate, compress -- peasypdf.com
peasy-image PyPI npm Gem Image resize, crop, convert, compress -- peasyimage.com
peasy-audio PyPI npm Gem Audio trim, merge, convert, normalize -- peasyaudio.com
peasy-video PyPI npm Gem Video trim, resize, thumbnails, GIF -- peasyvideo.com
peasy-css PyPI npm Gem CSS minify, format, analyze -- peasycss.com
peasy-compress PyPI npm Gem ZIP, TAR, gzip compression -- peasytools.com
peasy-document PyPI npm Gem Markdown, HTML, CSV, JSON conversion -- peasyformats.com
peasytext PyPI npm Gem Text case conversion, slugify, word count -- peasytext.com

Embed Widget

Embed PeasyCss widgets on any website with peasy-css-embed:

<script src="https://cdn.jsdelivr.net/npm/peasy-css-embed@1/dist/embed.min.js"></script>
<div data-peasycss="entity" data-slug="example"></div>

Zero dependencies · Shadow DOM · 4 themes (light/dark/sepia/auto) · Widget docs

License

MIT