TSS to STSS Converter
Convert Titanium Style Sheets (TSS) to Sassy Titanium Style Sheets (STSS) instantly in your browser. Paste TSS, get clean STSS output.
About
Titanium Style Sheets (TSS) use a JavaScript object-literal syntax to declare UI properties for Appcelerator Alloy views. Sassy Titanium Style Sheets (STSS) extend this with SCSS-like nesting, variables ($myColor), and mixins, compiled back to TSS by the stss preprocessor. Manually rewriting a project's TSS files to STSS is error-prone: a misplaced brace or a forgotten Titanium constant shorthand (Ti.UI.TEXT_ALIGNMENT_LEFT → left) breaks the entire build chain. This converter parses your TSS token-by-token, restructures selector blocks into nested STSS syntax, and applies constant optimizations automatically. It approximates the output of the tss2stss CLI tool under standard formatting assumptions. Edge case: deeply nested platform queries or runtime-evaluated expressions (Alloy.Globals.*) are passed through verbatim since they have no static STSS equivalent.
Formulas
The conversion follows a deterministic transformation pipeline. TSS uses quoted selectors as JavaScript object keys mapped to property objects. STSS uses unquoted, SCSS-style nested selectors.
Each TSS block of the form:"selector": { prop: value }
is transformed to:selector { prop: value; }
Where selector is unquoted and stripped of its surrounding double-quotes. The constant optimization step replaces known Ti.UI.* enumerations with their string shorthand equivalents per the Alloy STSS compiler specification. Properties that reference runtime expressions (e.g., Alloy.Globals.brandColor) are emitted verbatim since static resolution is not possible.
Reference Data
| TSS Titanium Constant | STSS Shorthand | Category |
|---|---|---|
Ti.UI.TEXT_ALIGNMENT_LEFT | left | Text Alignment |
Ti.UI.TEXT_ALIGNMENT_CENTER | center | Text Alignment |
Ti.UI.TEXT_ALIGNMENT_RIGHT | right | Text Alignment |
Ti.UI.TEXT_VERTICAL_ALIGNMENT_TOP | top | Vertical Alignment |
Ti.UI.TEXT_VERTICAL_ALIGNMENT_CENTER | center | Vertical Alignment |
Ti.UI.TEXT_VERTICAL_ALIGNMENT_BOTTOM | bottom | Vertical Alignment |
Ti.UI.SIZE | Ti.UI.SIZE | Layout (no shorthand) |
Ti.UI.FILL | Ti.UI.FILL | Layout (no shorthand) |
Ti.UI.UNIT_PX | px | Units |
Ti.UI.UNIT_DIP | dip | Units |
Ti.UI.UNIT_MM | mm | Units |
Ti.UI.UNIT_CM | cm | Units |
Ti.UI.UNIT_IN | in | Units |
Ti.UI.INPUT_BORDERSTYLE_NONE | none | Border Style |
Ti.UI.INPUT_BORDERSTYLE_ROUNDED | rounded | Border Style |
Ti.UI.INPUT_BORDERSTYLE_BEZEL | bezel | Border Style |
Ti.UI.INPUT_BORDERSTYLE_LINE | line | Border Style |
Ti.UI.AUTOLINK_ALL | all | Autolink |
Ti.UI.AUTOLINK_NONE | none | Autolink |
Ti.UI.KEYBOARD_TYPE_DEFAULT | default | Keyboard |
Ti.UI.KEYBOARD_TYPE_ASCII | ascii | Keyboard |
Ti.UI.KEYBOARD_TYPE_URL | url | Keyboard |
Ti.UI.KEYBOARD_TYPE_EMAIL | email | Keyboard |
Ti.UI.RETURN_KEY_TYPE_DONE | done | Return Key |
Ti.UI.RETURN_KEY_TYPE_GO | go | Return Key |
Ti.UI.RETURN_KEY_TYPE_NEXT | next | Return Key |
Ti.UI.RETURN_KEY_TYPE_SEARCH | search | Return Key |
Ti.UI.RETURN_KEY_TYPE_SEND | send | Return Key |