Comments

Last updated 2026-05-20

Copy-ready comment-thread JSON tied to posts and users. Fetch by post id, paginate, add, update, delete. Live REST endpoint at /comments.

Comments

fetch('https://jsonexamples.com/comments')
  .then(res => res.json())
  .then(console.log);
Response
{
  "comments": [
    { "id": 1, "body": "This is some awesome thinking!", "postId": 100, "user": { "id": 63, "username": "eburras1q" } }
    // 30 items
  ],
  "total": 340,
  "skip": 0,
  "limit": 30
}
fetch('https://jsonexamples.com/comments/1')
  .then(res => res.json())
  .then(console.log);
Response
{
  "id": 1,
  "body": "This is some awesome thinking!",
  "postId": 100,
  "user": { "id": 63, "username": "eburras1q" }
}
  • Use limit and skip for pagination.
  • Pass select with comma-separated keys to trim the payload.
fetch('https://jsonexamples.com/comments?limit=10&skip=10&select=body,postId')
  .then(res => res.json())
  .then(console.log);
Response
{
  "comments": [
    { "id": 11, "body": "It was a pleasure to grade this!", "postId": 2 }
    // 10 items
  ],
  "total": 340,
  "skip": 10,
  "limit": 10
}
/* getting comments of post with id 5 */
fetch('https://jsonexamples.com/comments/post/5')
  .then(res => res.json())
  .then(console.log);
Response
{
  "comments": [
    { "id": 64, "body": "You amaze me!", "postId": 5, "user": { "id": 39, "username": "lgherardi12" } }
  ],
  "total": 3,
  "skip": 0,
  "limit": 3
}
  • Adding a new comment will not persist on the server.
fetch('https://jsonexamples.com/comments/add', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    body: 'This makes all sense to me!',
    postId: 3,
    userId: 5,
  })
})
  .then(res => res.json())
  .then(console.log);
Response
{
  "id": 341,
  "body": "This makes all sense to me!",
  "postId": 3,
  "user": { "id": 5, "username": "kmeus4" }
}
/* updating body of comment with id 1 */
fetch('https://jsonexamples.com/comments/1', {
  method: 'PUT',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ body: 'I think I should shift to the moon' })
})
  .then(res => res.json())
  .then(console.log);
Response
{
  "id": 1,
  "body": "I think I should shift to the moon",
  "postId": 100,
  "user": { "id": 63, "username": "eburras1q" }
}
fetch('https://jsonexamples.com/comments/1', { method: 'DELETE' })
  .then(res => res.json())
  .then(console.log);
Response
{
  "id": 1,
  "body": "This is some awesome thinking!",
  "postId": 100,
  "isDeleted": true,
  "deletedOn": /* ISOTime */
}

Related examples