HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers10/honger7.komma.pro/node_modules/css-tree/docs/translate.md
# Translate AST to string

<!-- MarkdownTOC -->

- [translate\(ast\)](#translateast)
- [translateWithSourceMap\(ast\)](#translatewithsourcemapast)

<!-- /MarkdownTOC -->

## translate(ast)

Converts AST to string.

```js
var ast = csstree.parse('.test { color: red }');
console.log(csstree.translate(ast));
// > .test{color:red}
```

## translateWithSourceMap(ast)

The same as `translate()` but also generates source map (nodes should contain positions in `loc` property).

```js
var ast = csstree.parse('.test { color: red }', {
    filename: 'my.css',
    positions: true
});
console.log(csstree.translateWithSourceMap(ast));
// { css: '.test{color:red}', map: SourceMapGenerator {} }
```