---
# Don't modify this file manually. This file is auto generated from source, and you will lose your changes next time the website is built.
# Head to the `biomejs/biome` repository, and modify the source code in there.

title: useConsistentCurlyBraces
description: Learn more about useConsistentCurlyBraces
---
import { Tabs, TabItem } from '@astrojs/starlight/components';

<Tabs>
<TabItem label="JSX and TSX" icon="seti:javascript">
## Summary
- Rule available since: `v1.8.2`
- Diagnostic Category: [`lint/style/useConsistentCurlyBraces`](/reference/diagnostics#diagnostic-category)
- This rule isn't recommended, so you need to enable it.
- This rule has an [**unsafe**](/linter/#unsafe-fixes) fix.
- The default severity of this rule is [**information**](/reference/diagnostics#information).
- Sources: 
  - Inspired from [`react/jsx-curly-brace-presence`](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-curly-brace-presence.md)

## How to configure
```json title="biome.json"
{
	"linter": {
		"rules": {
			"style": {
				"useConsistentCurlyBraces": "error"
			}
		}
	}
}

```
## Description
This rule enforces consistent use of curly braces inside JSX attributes and JSX children.

For situations where JSX expressions are unnecessary, please refer to [the React doc](https://facebook.github.io/react/docs/jsx-in-depth.html) and [this page about JSX gotchas](https://github.com/facebook/react/blob/v15.4.0-rc.3/docs/docs/02.3-jsx-gotchas.md#html-entities).

This rule will check for and warn about unnecessary curly braces in both JSX props and children.

## Examples

### Invalid

```jsx
<Foo>{'Hello world'}</Foo>
```

<pre class="language-text"><code class="language-text">code-block.jsx:1:6 <a href="https://biomejs.dev/linter/rules/use-consistent-curly-braces">lint/style/useConsistentCurlyBraces</a> <span style="color: #000; background-color: #ddd;"> FIXABLE </span> ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━<br /><br />  <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">Should not have curly braces around expression.</span><br />  <br />  <strong><span style="color: Tomato;">&gt;</span></strong> <strong>1 │ </strong>&lt;Foo&gt;&#123;'Hello world'&#125;&lt;/Foo&gt;<br />   <strong>   │ </strong>     <strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><br />    <strong>2 │ </strong><br />  <br />  <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">JSX child does not need to be wrapped in curly braces.</span><br />  <br />  <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">Unsafe fix</span><span style="color: lightgreen;">: </span><span style="color: lightgreen;">Remove curly braces around the expression.</span><br />  <br />  <strong>  1 │ </strong>&lt;Foo&gt;<span style="color: Tomato;">&#123;</span><span style="color: Tomato;">'</span>Hello<span style="opacity: 0.8;">·</span>world<span style="color: Tomato;">'</span><span style="color: Tomato;">&#125;</span>&lt;/Foo&gt;<br />  <strong>    │ </strong>     <span style="color: Tomato;">-</span><span style="color: Tomato;">-</span>           <span style="color: Tomato;">-</span><span style="color: Tomato;">-</span>      <br /></code></pre>

```jsx
<Foo foo={'bar'} />
```

<pre class="language-text"><code class="language-text">code-block.jsx:1:10 <a href="https://biomejs.dev/linter/rules/use-consistent-curly-braces">lint/style/useConsistentCurlyBraces</a> <span style="color: #000; background-color: #ddd;"> FIXABLE </span> ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━<br /><br />  <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">Should not have curly braces around expression.</span><br />  <br />  <strong><span style="color: Tomato;">&gt;</span></strong> <strong>1 │ </strong>&lt;Foo foo=&#123;'bar'&#125; /&gt;<br />   <strong>   │ </strong>         <strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><br />    <strong>2 │ </strong><br />  <br />  <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">JSX attribute value does not need to be wrapped in curly braces.</span><br />  <br />  <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">Unsafe fix</span><span style="color: lightgreen;">: </span><span style="color: lightgreen;">Remove curly braces around the expression.</span><br />  <br />  <strong>  1 │ </strong>&lt;Foo<span style="opacity: 0.8;">·</span>foo=<span style="color: Tomato;">&#123;</span>'bar'<span style="color: Tomato;">&#125;</span><span style="opacity: 0.8;">·</span>/&gt;<br />  <strong>    │ </strong>         <span style="color: Tomato;">-</span>     <span style="color: Tomato;">-</span>   <br /></code></pre>

```jsx
<Foo foo=<Bar /> />
```

<pre class="language-text"><code class="language-text">code-block.jsx:1:10 <a href="https://biomejs.dev/linter/rules/use-consistent-curly-braces">lint/style/useConsistentCurlyBraces</a> <span style="color: #000; background-color: #ddd;"> FIXABLE </span> ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━<br /><br />  <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">Should have curly braces around expression.</span><br />  <br />  <strong><span style="color: Tomato;">&gt;</span></strong> <strong>1 │ </strong>&lt;Foo foo=&lt;Bar /&gt; /&gt;<br />   <strong>   │ </strong>         <strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><br />    <strong>2 │ </strong><br />  <br />  <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">JSX attribute value should be wrapped in curly braces. This will make the JSX attribute value more readable.</span><br />  <br />  <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">Unsafe fix</span><span style="color: lightgreen;">: </span><span style="color: lightgreen;">Add curly braces around the expression.</span><br />  <br />  <strong>  1 │ </strong>&lt;Foo<span style="opacity: 0.8;">·</span>foo=<span style="color: MediumSeaGreen;">&#123;</span>&lt;Bar<span style="opacity: 0.8;">·</span>/&gt;<span style="color: MediumSeaGreen;">&#125;</span><span style="opacity: 0.8;">·</span>/&gt;<br />  <strong>    │ </strong>         <span style="color: MediumSeaGreen;">+</span>       <span style="color: MediumSeaGreen;">+</span>   <br /></code></pre>

### Valid

```jsx
<>
    <Foo>Hello world</Foo>
    <Foo foo="bar" />
    <Foo foo={5} />
    <Foo foo={<Bar />} />
</>
```

## Related links

- [Disable a rule](/linter/#disable-a-rule)
- [Configure the code fix](/linter#configure-the-code-fix)
- [Rule options](/linter/#rule-options)
- [Source Code](https://github.com/biomejs/biome/blob/main/crates/biome_js_analyze/src/lint/style/use_consistent_curly_braces.rs)
- [Test Cases](https://github.com/biomejs/biome/blob/main/crates/biome_js_analyze/tests/specs/style/useConsistentCurlyBraces)

</TabItem>
</Tabs>