# Import a JSON5 file (/docs/guides/runtime/import-json5)

<!-- agent-signals: reading_time_min: 1 · est_tokens: 314 · updated: 2026-07-28 -->
Related: [Delete directories](/docs/guides/runtime/delete-directory.md), [Delete files](/docs/guides/runtime/delete-file.md), [Import a HTML file as text](/docs/guides/runtime/import-html.md), [Import a JSON file](/docs/guides/runtime/import-json.md), [Import a TOML file](/docs/guides/runtime/import-toml.md), [Import a YAML file](/docs/guides/runtime/import-yaml.md)

Bun natively supports `.json5` imports.

```json5 config.json5 icon="file-code"
{
  // Comments are allowed
  database: {
    host: "localhost",
    port: 5432,
    name: "myapp",
  },

  server: {
    port: 3000,
    timeout: 30,
  },

  features: {
    auth: true,
    rateLimit: true,
  },
}
```

***

Import the file like any other source file.

```ts config.ts icon="/icons/typescript.svg"
import config from "./config.json5";

config.database.host; // => "localhost"
config.server.port; // => 3000
config.features.auth; // => true
```

***

You can also use named imports to destructure top-level properties:

```ts config.ts icon="/icons/typescript.svg"
import { database, server, features } from "./config.json5";

console.log(database.name); // => "myapp"
console.log(server.timeout); // => 30
console.log(features.rateLimit); // => true
```

***

For parsing JSON5 strings at runtime, use `Bun.JSON5.parse()`:

```ts config.ts icon="/icons/typescript.svg"
const data = Bun.JSON5.parse(`{
  name: 'John Doe',
  age: 30,
  hobbies: [
    'reading',
    'coding',
  ],
}`);

console.log(data.name); // => "John Doe"
console.log(data.hobbies); // => ["reading", "coding"]
```

***

See [JSON5](/runtime/json5) for the rest of Bun's JSON5 support.
