--- id: lesscpy version: "0.15.2" license: MIT license_treatment: permissive maintenance: active --- # lesscpy — Python LESS compiler License: permissive · Maintenance: active · Downloads: 179.9K/mo ## What it is and what it does Lesscpy is a Python implementation of a LESS-to-CSS compiler that lets you use LESS stylesheets in environments where Node.js is unavailable or undesirable. It tokenizes and parses LESS syntax using PLY (Python Lex-Yacc) and outputs valid CSS. The package supports a substantial subset of LESS features including variables, mixins with nesting and recursion, guard expressions, color manipulation functions, and string interpolation. You can use it either as a command-line tool (with options for minification, includes, and output control) or programmatically by calling `lesscpy.compile()` on a file-like object or string. The main trade-off is speed: it runs slower than the Node.js reference implementation because it's written in Python, and it does not support JavaScript evaluation within LESS files. All colors are normalized to six-digit hex format, and CSS comments are not preserved. Use it for: - Compile LESS stylesheets in Python web frameworks (Django, Flask) without a Node.js dependency - Integrate LESS compilation into Python-based build pipelines or static site generators - Process LESS files in containerized or restricted environments where Node.js cannot be installed - Automate stylesheet preprocessing in CI/CD workflows using only Python tooling - Support LESS in legacy Python projects that cannot adopt modern JavaScript tooling ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Compiles LESS stylesheets to CSS using Python, without requiring Node.js. Supports variables, mixins, nesting, color functions, and guard expressions, but not JavaScript evaluation. Yes, if you need LESS compilation in a Python-only environment and can accept slower performance than Node.js. The low install friction, active maintenance, MIT license, and lack of vulnerabilities make it a straightforward choice. No, if you already have Node.js available or require JavaScript evaluation within LESS files—use the reference compiler instead. ## Install pip install lesscpy uv add lesscpy poetry add lesscpy ## Installing lesscpy Before you install: Low friction: pure Python wheel with a single runtime dependency (ply). Active maintenance with a release 15 days ago and last commit on 2026-07-30. Stable production status and no known vulnerabilities. License in practice: MIT license permits commercial and private use with minimal restrictions, making it safe to integrate into most projects without licensing concerns. Quickstart: from io import StringIO import lesscpy result = lesscpy.compile(StringIO("a { border-width: 2px * 3; }"), minify=True) print(result) Requires Python 3.11 or later Verify before relying: - Whether the package's performance characteristics (described as 'considerably slower than the Node.js compiler') are acceptable for your build pipeline - Completeness of LESS feature coverage beyond the listed supported features for your specific stylesheets ## Package facts - License: MIT (permissive) - Python support: unspecified - Install friction: low - Maintenance: active - Downloads: 179.9K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags less compiler python, less to css conversion, python less preprocessor, lesscss compiler, less stylesheet compiler, css preprocessor python, less language support, css-preprocessing, less-compiler, build-tool [View on SkillFed](https://skillfed.io/packages/lesscpy) · [View on PyPI](https://pypi.org/project/lesscpy/)