# How to format code?

**URL:** <https://talk.observablehq.com/t/how-to-format-code/3965>\
**Category:** Help\
**Created:** [October 3, 2020, 3:55am UTC](https://talk.observablehq.com/t/how-to-format-code/3965 "2020-10-03T03:55:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dacapoday](https://avatars.discourse-cdn.com/v4/letter/d/b487fb/32.png) [@dacapoday](https://talk.observablehq.com/u/dacapoday)\
**Post date:** [October 3, 2020, 3:55am UTC](https://talk.observablehq.com/t/how-to-format-code/3965/1 "2020-10-03T03:55:58Z")

</div>

In VSCode, i can format code by format doc.  
How to do it in Observable?

---

<div class="post-metadata">

**Author:** ![aaronkyle](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/aaronkyle/32/8106_2.png) [@aaronkyle](https://talk.observablehq.com/u/aaronkyle)\
**Post date:** [October 3, 2020, 4:02am UTC](https://talk.observablehq.com/t/how-to-format-code/3965/2 "2020-10-03T04:02:35Z")

</div>

Hi @dacapoday, and welcome to the forum!

Out of curiosity, does this thread respond to your question?

> [@"prettier" code formatting](https://talk.observablehq.com/t/prettier-code-formatting/365):
>
> One thing that I miss from working in my own editor is [prettier](https://www.npmjs.com/package/prettier) formatting on save. I know Observable editor won’t have every code editor feature available, but this could be a nice option. (I bet this could be done as a user-script plugin, hooked into shift+enter.)

---

<div class="post-metadata">

**Author:** ![Cobus](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/cobus/32/9670_2.png) [@Cobus](https://talk.observablehq.com/u/Cobus)\
**Post date:** [October 5, 2020, 11:19pm UTC](https://talk.observablehq.com/t/how-to-format-code/3965/3 "2020-10-05T23:19:46Z")

</div>

There are a few formatting options for your code in Observable which you can select in your Settings (see attached)

 ![image](https://canada1.discourse-cdn.com/flex030/uploads/observablehq/original/2X/4/472b0788cb0a9c9aa0147258a7e9087dfb3f4d64.jpeg)

---

<div class="post-metadata">

**Author:** ![mootari](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/mootari/32/581_2.png) [@mootari](https://talk.observablehq.com/u/mootari)\
**Post date:** [September 5, 2021, 10:15am UTC](https://talk.observablehq.com/t/how-to-format-code/3965/4 "2021-09-05T10:15:28Z")

</div>

You can also use the shortcut Shift-Option-F to apply code formatting to a cell manually.

Related:

> <https://github.com/observablehq/feedback/issues/205>
>
> \*\*Describe the bug\*\*
> 
> The shortcut \<kbd\>Shift\</kbd\>-\<kbd\>Option\</kbd\>-\<kbd\>F\</…kbd\> applies Prettier formatting to a cell.
> 
> However, this shortcut is missing from the list of shortcuts in the help flyout, and appears to be undocumented in general.
> 
> \*\*Additional context\*\*
> 
> On 2021-04-23 @wiltsecarpenter \[mentioned\](https://observablehq.slack.com/archives/C01LADG5CF6/p1619197682128300) adding the shortcut for macOS.
