# How to add code example in code block section?

**URL:** <https://community.postman.com/t/how-to-add-code-example-in-code-block-section/60555>\
**Category:** Help Hub\
**Tags:** collections\
**Created:** [May 2, 2024, 8:23am UTC](https://community.postman.com/t/how-to-add-code-example-in-code-block-section/60555 "2024-05-02T08:23:31Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![pratimamariserla](https://avatars.discourse-cdn.com/v4/letter/p/c5a1d2/32.png) [@pratimamariserla](https://community.postman.com/u/pratimamariserla)\
**Post date:** [May 2, 2024, 8:23am UTC](https://community.postman.com/t/how-to-add-code-example-in-code-block-section/60555/1 "2024-05-02T08:23:31Z")

</div>

When adding a code example within a code block, upon saving the documentation, the inserted code example and other content become merged, resulting in a disorganized presentation.

---

<div class="post-metadata">

**Author:** ![gbadebo-bello](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/gbadebo-bello/32/12175_2.png) [@gbadebo-bello](https://community.postman.com/u/gbadebo-bello)\
**Post date:** [May 2, 2024, 3:12pm UTC](https://community.postman.com/t/how-to-add-code-example-in-code-block-section/60555/2 "2024-05-02T15:12:14Z")

</div>

Hi @pratimamariserla. Welcome to the Postman Community!

Can you share a screenshot(s) of what you’re trying to describe?

---

<div class="post-metadata">

**Author:** ![pratimamariserla](https://avatars.discourse-cdn.com/v4/letter/p/c5a1d2/32.png) [@pratimamariserla](https://community.postman.com/u/pratimamariserla)\
**Post date:** [May 3, 2024, 10:41am UTC](https://community.postman.com/t/how-to-add-code-example-in-code-block-section/60555/3 "2024-05-03T10:41:36Z")

</div>

![Screenshot 2024-04-25 at 10.40.50 AM](https://us1.discourse-cdn.com/getpostman/original/3X/7/0/70456cc2f211854b2975aa08dd5907a61a61b469.jpeg)  
 ![Screenshot 2024-04-25 at 10.42.26 AM](https://us1.discourse-cdn.com/getpostman/original/3X/b/a/ba70b88cf5ec2065695885841272a5c02305d0df.jpeg)  
Hi @gbadebo-bello ,  
Thank you for your prompt response 🙂 .  
I have included both screenshots:

1. The first screenshot depicts the example code within a code block.
2. The second screenshot illustrates the content after saving.

---

<div class="post-metadata">

**Author:** ![gbadebo-bello](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/gbadebo-bello/32/12175_2.png) [@gbadebo-bello](https://community.postman.com/u/gbadebo-bello)\
**Post date:** [May 3, 2024, 1:46pm UTC](https://community.postman.com/t/how-to-add-code-example-in-code-block-section/60555/4 "2024-05-03T13:46:44Z")

</div>

Hi @pratimamariserla. You’re adding the code sample, but have selected “Plain Text” as the format which is why the code doesn’t get any formatting. At the to left menu in the code input box, toggle it and select “JavaScript”. This will enable formatting and syntax highlighting for your javascript code.

---

<div class="post-metadata">

**Author:** ![pratimamariserla](https://avatars.discourse-cdn.com/v4/letter/p/c5a1d2/32.png) [@pratimamariserla](https://community.postman.com/u/pratimamariserla)\
**Post date:** [May 6, 2024, 6:03am UTC](https://community.postman.com/t/how-to-add-code-example-in-code-block-section/60555/5 "2024-05-06T06:03:44Z")

</div>

Hello @gbadebo-bello, I have attempted to select another language for formatting, but it yields the same result. Attached is a screenshot for reference.

 ![Image 06-05-24 at 11.32 AM](https://us1.discourse-cdn.com/getpostman/original/3X/1/0/106d9dea80f1615610f6e23fcba028d0addeefea.jpeg)

I attempted to manually add a code example, but the result appears as follows.

 ![Image 06-05-24 at 11.38 AM](https://us1.discourse-cdn.com/getpostman/original/3X/e/d/ede8e4b96a92241306199c129962f35e818ad422.jpeg)

---

<div class="post-metadata">

**Author:** ![gbadebo-bello](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/gbadebo-bello/32/12175_2.png) [@gbadebo-bello](https://community.postman.com/u/gbadebo-bello)\
**Post date:** [May 6, 2024, 11:48am UTC](https://community.postman.com/t/how-to-add-code-example-in-code-block-section/60555/6 "2024-05-06T11:48:17Z")

</div>

Hi @pratimamariserla. If you select “JavaScript” as the formatting language, then you have to only provide Javascript code to the text editor. Here you’re providing HTML code instead.

---

<div class="post-metadata">

**Author:** ![pratimamariserla](https://avatars.discourse-cdn.com/v4/letter/p/c5a1d2/32.png) [@pratimamariserla](https://community.postman.com/u/pratimamariserla)\
**Post date:** [May 10, 2024, 6:29am UTC](https://community.postman.com/t/how-to-add-code-example-in-code-block-section/60555/7 "2024-05-10T06:29:57Z")

</div>

Hi @gbadebo-bello,Currently, I’m exclusively inputting JavaScript code into the text editor and selecting the JavaScript option. However, it consistently produces the same error.

---

<div class="post-metadata">

**Author:** ![gbadebo-bello](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/gbadebo-bello/32/12175_2.png) [@gbadebo-bello](https://community.postman.com/u/gbadebo-bello)\
**Post date:** [May 10, 2024, 12:30pm UTC](https://community.postman.com/t/how-to-add-code-example-in-code-block-section/60555/8 "2024-05-10T12:30:28Z")

</div>

Hi @pratimamariserla.

Can you share a screenshot of what you currently have?

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/system/32/29796_2.png) [@system](https://community.postman.com/u/system)\
**Post date:** [June 9, 2024, 12:31pm UTC](https://community.postman.com/t/how-to-add-code-example-in-code-block-section/60555/9 "2024-06-09T12:31:24Z")

</div>

Closed on June 9, 2024, 12:31pm UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
