# Request body should be able to be commented

**URL:** <https://community.postman.com/t/request-body-should-be-able-to-be-commented/8288>\
**Category:** Help Hub\
**Tags:** comments, body, request, documentation, tests\
**Created:** [October 10, 2019, 10:43am UTC](https://community.postman.com/t/request-body-should-be-able-to-be-commented/8288 "2019-10-10T10:43:06Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![DengBunthai](https://avatars.discourse-cdn.com/v4/letter/d/3e96dc/32.png) [@DengBunthai](https://community.postman.com/u/DengBunthai)\
**Post date:** [October 10, 2019, 10:43am UTC](https://community.postman.com/t/request-body-should-be-able-to-be-commented/8288/1 "2019-10-10T10:43:06Z")

</div>

I think it’s easier if request body can be commented. 👇  
{  
“product”: “{{displayName}}”,  
// “price” : “15.5”  
}

Sorry in advance, I am not sure what to tag to.

---

<div class="post-metadata">

**Author:** ![vdespa](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/vdespa/32/2770_2.png) [@vdespa](https://community.postman.com/u/vdespa)\
**Post date:** [October 10, 2019, 1:18pm UTC](https://community.postman.com/t/request-body-should-be-able-to-be-commented/8288/2 "2019-10-10T13:18:41Z")

</div>

JSON, the format used, does not allow comments.

---

<div class="post-metadata">

**Author:** ![DengBunthai](https://avatars.discourse-cdn.com/v4/letter/d/3e96dc/32.png) [@DengBunthai](https://community.postman.com/u/DengBunthai)\
**Post date:** [October 10, 2019, 1:39pm UTC](https://community.postman.com/t/request-body-should-be-able-to-be-commented/8288/3 "2019-10-10T13:39:45Z")

</div>

Thank you for your answer, I also expect this answer.  
I think we are using Postman, it is a tool.  
The commenting out should be helped by the tool also. The testing should be easier if it can be commented out. If It is still insisted json can’t be commented out. It should be found a better ways.

---

<div class="post-metadata">

**Author:** ![DengBunthai](https://avatars.discourse-cdn.com/v4/letter/d/3e96dc/32.png) [@DengBunthai](https://community.postman.com/u/DengBunthai)\
**Post date:** [October 11, 2019, 1:34am UTC](https://community.postman.com/t/request-body-should-be-able-to-be-commented/8288/4 "2019-10-11T01:34:21Z")

</div>

As you can see we can embed a variable into the json body. The reason is Postman is a tool.  
For example, before I post a request body in JS IDE, I also can comment out those json in the IDE also.  
Why can’t Postman comment it out?

---

<div class="post-metadata">

**Author:** ![vdespa](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/vdespa/32/2770_2.png) [@vdespa](https://community.postman.com/u/vdespa)\
**Post date:** [October 11, 2019, 7:58pm UTC](https://community.postman.com/t/request-body-should-be-able-to-be-commented/8288/5 "2019-10-11T19:58:00Z")

</div>

Which IDE supports that?

---

<div class="post-metadata">

**Author:** ![DengBunthai](https://avatars.discourse-cdn.com/v4/letter/d/3e96dc/32.png) [@DengBunthai](https://community.postman.com/u/DengBunthai)\
**Post date:** [October 12, 2019, 12:37am UTC](https://community.postman.com/t/request-body-should-be-able-to-be-commented/8288/6 "2019-10-12T00:37:17Z")

</div>

I mentioned about JS IDE, it is my mistake.  
I confused between an JS object and json object. I think probably this suggestion will not work.

Thank you for your reply.

---

<div class="post-metadata">

**Author:** ![DengBunthai](https://avatars.discourse-cdn.com/v4/letter/d/3e96dc/32.png) [@DengBunthai](https://community.postman.com/u/DengBunthai)\
**Post date:** [October 14, 2019, 5:45am UTC](https://community.postman.com/t/request-body-should-be-able-to-be-commented/8288/7 "2019-10-14T05:45:52Z")

</div>

I think I found some solution of solving my problem:

=========================

**Body Tab:**  
`{{object}}`

=========================

**Pre-request Script Tab:**  
object = {  
// product: “{{displayName}}”,  
price : “15.5”  
}  
pm.environment.set(“object”, JSON.stringify(object));

========================

---

<div class="post-metadata">

**Author:** ![vdespa](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/vdespa/32/2770_2.png) [@vdespa](https://community.postman.com/u/vdespa)\
**Post date:** [October 14, 2019, 6:08pm UTC](https://community.postman.com/t/request-body-should-be-able-to-be-commented/8288/8 "2019-10-14T18:08:58Z")

</div>

This is actually not a bad idea. I am glad you have found a solution and thank you for sharing👍

---

<div class="post-metadata">

**Author:** ![rlabatt](https://avatars.discourse-cdn.com/v4/letter/r/a6a055/32.png) [@rlabatt](https://community.postman.com/u/rlabatt)\
**Post date:** [November 21, 2020, 2:26am UTC](https://community.postman.com/t/request-body-should-be-able-to-be-commented/8288/9 "2020-11-21T02:26:45Z")

</div>

It would be _much_ easier and appreciated if we could use javascript style commenting. It’s easy and everyone knows the meaning of //

---

<div class="post-metadata">

**Author:** ![dpchudasama2](https://avatars.discourse-cdn.com/v4/letter/d/7ea924/32.png) [@dpchudasama2](https://community.postman.com/u/dpchudasama2)\
**Post date:** [August 12, 2021, 7:12am UTC](https://community.postman.com/t/request-body-should-be-able-to-be-commented/8288/10 "2021-08-12T07:12:29Z")

</div>

I know that this is not that much good answer but for comment in JSON of postman I am adding new key which should not in use server side, which can help us to add some comment  
Original json:  
{  
“name”: “My Name”,  
“age”: 99  
}

for comment:  
{  
“name”: “My Name”,  
“age”: 99,  
“\_COMMENT$”: “This is my comment, but make sure that use some keyname which should not in use server side…”  
}

---

<div class="post-metadata">

**Author:** ![mspreafico](https://avatars.discourse-cdn.com/v4/letter/m/e9a140/32.png) [@mspreafico](https://community.postman.com/u/mspreafico)\
**Post date:** [April 13, 2022, 10:23am UTC](https://community.postman.com/t/request-body-should-be-able-to-be-commented/8288/11 "2022-04-13T10:23:52Z")

</div>

There are a lot of json processors able to handle comments (think to DotNet Core settings files for example). Postman could simply and automatically do what’s suggested here: [How to place comments in Postman - Stack Overflow](https://stackoverflow.com/a/67467079/182547)

Bear in mind that the current Postman behavior can cause very weird errors/responses from the servers, today we spent 2 hours debugging the server side code before realizing the problem was a comment in the request body.

---

<div class="post-metadata">

**Author:** ![xpario](https://avatars.discourse-cdn.com/v4/letter/x/7ea924/32.png) [@xpario](https://community.postman.com/u/xpario)\
**Post date:** [May 16, 2022, 3:07pm UTC](https://community.postman.com/t/request-body-should-be-able-to-be-commented/8288/12 "2022-05-16T15:07:18Z")

</div>

I LOVE the suggestion from @dpchudasama2([Profile - dpchudasama2 - Postman](https://community.postman.com/u/dpchudasama2)) - assuming POSTMAN doesn’t figure out this a simple request and do something proper about it. You can use it to comment/document fields. example:

“COMMENT\_name” : “This field can accept only alphabetic characters”

---

<div class="post-metadata">

**Author:** ![elkadrey](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/elkadrey/32/13053_2.png) [@elkadrey](https://community.postman.com/u/elkadrey)\
**Post date:** [August 29, 2022, 9:06am UTC](https://community.postman.com/t/request-body-should-be-able-to-be-commented/8288/13 "2022-08-29T09:06:38Z")

</div>

I’ve got a prfect soluation just add this following code in the main collection \> pre-request script to strip all comments from json raw

```auto
if(pm.request.body && pm.request.body.raw) pm.request.body.raw = pm.request.body.raw.replace(/\/\*[\s\S]*?\*\/|\/\/.*/g,'');

```

 ![download](https://us1.discourse-cdn.com/getpostman/original/2X/7/7e6690c2d77479f27cf022fcb5e4b4741620da16.png)

![download (1)](https://us1.discourse-cdn.com/getpostman/original/2X/8/8a34aa7822f1d7180dedc7bee4465f66a7d8c3a3.png)

---

<div class="post-metadata">

**Author:** ![ruedigerm](https://avatars.discourse-cdn.com/v4/letter/r/c89c15/32.png) [@ruedigerm](https://community.postman.com/u/ruedigerm)\
**Post date:** [February 2, 2023, 12:54pm UTC](https://community.postman.com/t/request-body-should-be-able-to-be-commented/8288/14 "2023-02-02T12:54:18Z")

</div>

very nice solution @elkadrey

For me, the usecase is more like this, but your solution works perfectly  
 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/7/b/7b265058fc2dc432c93147c8370b5db71179c7e3.png)
