# Custom theme from JSON (/recipes/custom-theme-from-json)

Use a theme JSON file produced by the
[Neovim colorscheme generation recipe](/recipes/generate-theme-from-neovim-colorscheme),
or your own theme definition. Keep its source license and notices with it.

### JavaScript / TypeScript

```js
import theme from './my_theme.json' with { type: 'json' };
import { highlight } from '@lumis-sh/lumis';
import { htmlInline } from '@lumis-sh/lumis/formatters';
import javascript from '@lumis-sh/wasm-javascript';

const html = await highlight(
  'const x = 1',
  htmlInline({ language: javascript, theme }),
);
```

Use Node.js JSON modules or a bundler with JSON import support. Install
`@lumis-sh/lumis` and `@lumis-sh/wasm-javascript` for this example.

### Rust

```rust
use lumis::themes;

let theme = themes::from_file("my_theme.json").unwrap();
```

### Elixir

```elixir
theme_json = File.read!("my_theme.json")
{:ok, theme} = Lumis.Theme.from_json(theme_json)

Lumis.highlight!("# a comment",
  formatter:
    {:html_inline, language: "elixir", theme: theme}
)
```

Install the `:lumis_wasm_elixir` parser dependency for this example.
`Lumis.Theme.from_file/1` combines reading and parsing when you have a file path.