How to delete multiple comments from issues
Platform Notice: Cloud Only - This article only applies to Atlassian products on the cloud platform.
Summary
Adding unlimited comments to issues often resulted in unusual load times, which in some cases caused reliability and performance problems.
With many comments across different issues and a lack of good ways to delete them in bulk (JRACLOUD-91983 - Delete multiple comments from a ticket at once), we don’t expect you to jump into your issues and remove the comments one by one.
Solution
Jira doesn’t have an easy way to delete comments in bulk. Below are some options:
Option 1: Delete all comments with Jira Automation
You can use Jira Cloud’s automation to delete comments in bulk.
To create a rule that deletes all comments (the comments can't be restored):
Go to the Automation Rules page.
Select Create automation.
Specify rule details as follows:
Trigger: Manual trigger
Advanced branching:
Smart value: {{issue.comments.id}}
Variable name: commentId
Action: Delete comment
comment id: {{commentId}}
Option 2: Delete comments older than a specific date with API
The following pages link to APIs used to delete issue comments.
Get a list of comment IDs under an issue: GET comments
Delete a comment based on its ID: DELETE comment
Below is an example of a Python script that can be used to delete comments:
Remember to install python3 first and then jira and requests libraries before running it.
The advantage of using the API is that you can define a cutoff date and only delete comments older than the cutoff date.
Please be aware that the usage of the below script is not supported.
Python Script:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
from jira import JIRA
from datetime import datetime
import requests
from requests.auth import HTTPBasicAuth
def delete_old_comments(email, token, domain, issue_key, date_str):
# Connect to Jira
options = {'server': f'https://{domain}.atlassian.net'}
jira = JIRA(options, basic_auth=(email, token))
try:
# Parse the input date
cutoff_date = datetime.strptime(date_str, '%Y-%m-%d')
# Get the issue
issue = jira.issue(issue_key)
# Retrieve all comments
comments = jira.comments(issue)
# Iterate over comments and delete those older than the cutoff date
for comment in comments:
comment_created = datetime.strptime(comment.created.split('T')[0], '%Y-%m-%d')
if comment_created < cutoff_date:
# Delete the comment using REST API
comment_url = f"https://{domain}.atlassian.net/rest/api/3/issue/{issue_key}/comment/{comment.id}"
response = requests.delete(
comment_url,
auth=HTTPBasicAuth(email, token)
)
if response.status_code == 204:
print(f"Deleted comment {comment.id} created on {comment.created}: {comment.body[:50]}...")
else:
print(f"Failed to delete comment {comment.id}. Status code: {response.status_code}")
except Exception as e:
print(f"An error occurred: {e}")
if __name__ == '__main__':
#Define your inputs here
email = '' #your email
api_token = '' #your token
domain = '' #your Jira domain, only the one before %.atlassian.net
issue_key = 'KEY-1234' #the issue key
date_str = '2025-01-01' #Format: YYYY-MM-DD
# Call the function with the specified inputs
delete_old_comments(email, api_token, domain, issue_key, date_str)
Was this helpful?