PHPackages                             wikimedia/cssjanus - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. wikimedia/cssjanus

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

wikimedia/cssjanus
==================

Convert CSS stylesheets between left-to-right and right-to-left.

v2.3.0(1y ago)2746.2k—8.8%22Apache-2.0PHPPHP &gt;=7.4.0

Since Sep 25Pushed 2mo ago19 watchersCompare

[ Source](https://github.com/wikimedia/php-cssjanus)[ Packagist](https://packagist.org/packages/wikimedia/cssjanus)[ Docs](https://www.mediawiki.org/wiki/CSSJanus)[ RSS](/packages/wikimedia-cssjanus/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (4)Versions (13)Used By (2)

[![Packagist](https://camo.githubusercontent.com/b7b84725b5c1281c4efc8b379579aa53ec120cb39559fa6cf655bf8209fc8788/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f77696b696d656469612f6373736a616e75732e7376673f7374796c653d666c6174)](https://packagist.org/packages/wikimedia/cssjanus)

CSSJanus
========

[](#cssjanus)

Convert CSS stylesheets between left-to-right and right-to-left.

Usage
-----

[](#usage)

```
transform( string $css, bool $swapLtrInURL = false, bool $swapLeftInURL = false ) : string
```

Parameters;

- `$css` (string) Stylesheet to transform.
- `$swapLtrInURL` (boolean) Swap `ltr` to `rtl` direction in URLs.
- `$swapLeftInURL` (boolean) Swap `left` and `right` edges in URLs.

Example:

```
$rtlCss = CSSJanus::transform( $ltrCss );
```

### Preventing flipping

[](#preventing-flipping)

If a rule is not meant to be flipped by CSSJanus, use a `/* @noflip */` comment to protect the rule.

```
.rule1 {
  /* Will be converted to margin-right */
  margin-left: 1em;
}
/* @noflip */
.rule2 {
  /* Will be preserved as margin-left */
  margin-left: 1em;
}
```

CSS Logical Properties
----------------------

[](#css-logical-properties)

We encourage and recommend use of [CSS logical properties](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_logical_properties_and_values) for the subset of CSS features where a native direction-aware version of a CSS property exists (be sure to check [browser support](https://caniuse.com/) for specific properties). You can, for example, set properties like `margin-inline-start` instead of `margin-left`, which the browser flips based on content direction, and work seamlessly alongside other CSS properties that CSSJanus flips instead.

Note that CSS logical properties flip based on nearest content direction and content language, whereas CSSJanus is generally configured to flip by user language and UI direction.

Port
----

[](#port)

CSSJanus was originally a [Google project](http://code.google.com/p/cssjanus/) created by Lindsey Simon in 2008, written in Python. It was ported to PHP by Roan Kattouw in 2010 for use in MediaWiki, and ported to Node.js by Trevor Parscal in 2012.

As of 2014, the canonical specification and reference implementation is [node-cssjanus](https://gerrit.wikimedia.org/g/mediawiki/libs/node-cssjanus), which is then ported to PHP after each release.

Contribute
----------

[](#contribute)

- Issue tracker:
- Source code:
- Submit patches via Gerrit: [https://www.mediawiki.org/wiki/Developer\_account](https://www.mediawiki.org/wiki/Developer_account)

###  Health Score

54

—

FairBetter than 97% of packages

Maintenance63

Regular maintenance activity

Popularity44

Moderate usage in the ecosystem

Community29

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor1

Top contributor holds 54.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~327 days

Recently: every ~296 days

Total

12

Last Release

650d ago

Major Versions

v1.3.0 → v2.0.02021-05-10

PHP version history (6 changes)v1.1.0PHP &gt;=5.3.3

v1.2.0PHP &gt;=5.4

v1.2.1PHP &gt;=5.5.9

v1.3.0PHP &gt;=5.6.0

v2.0.0PHP &gt;=7.2.0

v2.1.1PHP &gt;=7.4.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/716c86d71cbf921e7912a505f89d799de398fc0a3af0bd4c8862834b2d642bd7?d=identicon)[wikimedia](/maintainers/wikimedia)

![](https://www.gravatar.com/avatar/a91173408bf645b6ff78a309a9e55bde405d29c72e2b1ae8ec9f9df1225f76c3?d=identicon)[Krinkle](/maintainers/Krinkle)

![](https://www.gravatar.com/avatar/fb7225bfe174e81de548c48d7ac39da81bcbd46a838fdede536b5b045ec85961?d=identicon)[bd808](/maintainers/bd808)

---

Top Contributors

[![Krinkle](https://avatars.githubusercontent.com/u/156867?v=4)](https://github.com/Krinkle "Krinkle (55 commits)")[![reedy](https://avatars.githubusercontent.com/u/67615?v=4)](https://github.com/reedy "reedy (11 commits)")[![jdforrester](https://avatars.githubusercontent.com/u/881572?v=4)](https://github.com/jdforrester "jdforrester (10 commits)")[![umherirrender](https://avatars.githubusercontent.com/u/1174884?v=4)](https://github.com/umherirrender "umherirrender (8 commits)")[![ebraminio](https://avatars.githubusercontent.com/u/833473?v=4)](https://github.com/ebraminio "ebraminio (3 commits)")[![edg2s](https://avatars.githubusercontent.com/u/180672?v=4)](https://github.com/edg2s "edg2s (3 commits)")[![ricordisamoa](https://avatars.githubusercontent.com/u/4588496?v=4)](https://github.com/ricordisamoa "ricordisamoa (2 commits)")[![catrope](https://avatars.githubusercontent.com/u/260792?v=4)](https://github.com/catrope "catrope (2 commits)")[![mattflaschen](https://avatars.githubusercontent.com/u/505874?v=4)](https://github.com/mattflaschen "mattflaschen (2 commits)")[![MatmaRex](https://avatars.githubusercontent.com/u/160413?v=4)](https://github.com/MatmaRex "MatmaRex (1 commits)")[![anomiex](https://avatars.githubusercontent.com/u/1030580?v=4)](https://github.com/anomiex "anomiex (1 commits)")[![anny21](https://avatars.githubusercontent.com/u/34449508?v=4)](https://github.com/anny21 "anny21 (1 commits)")[![MaxSem](https://avatars.githubusercontent.com/u/1260606?v=4)](https://github.com/MaxSem "MaxSem (1 commits)")[![thiemowmde](https://avatars.githubusercontent.com/u/6576639?v=4)](https://github.com/thiemowmde "thiemowmde (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/wikimedia-cssjanus/health.svg)

```
[![Health](https://phpackages.com/badges/wikimedia-cssjanus/health.svg)](https://phpackages.com/packages/wikimedia-cssjanus)
```

###  Alternatives

[jowy/feature

Feature flagging API used for operational rampups and A/B testing.

3045.4k1](/packages/jowy-feature)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
