# Bulk Category Creation via CSV

**URL:** <https://meta.discourse.org/t/bulk-category-creation-via-csv/159867>\
**Category:** Feature\
**Created:** [August 5, 2020, 7:04am UTC](https://meta.discourse.org/t/bulk-category-creation-via-csv/159867 "2020-08-05T07:04:24Z")\
**Posts on this page:** 3\
**Page:** 1

## AI-generated summary

**Bulk Category Creation via CSV**

Users are discussing the need for bulk category creation in Discourse. [markersocial](/t/-/159867/1) proposed a feature to support bulk category creation via CSV upload, similar to tag uploads. They suggested a simple CSV format with columns for category, subcategory, and description.

[markersocial](/t/-/159867/1) also referenced an existing solution using JSON files, but found it tedious to create and assign IDs correctly.

In response, [pfaffman](/t/-/159867/2) suggested writing a Ruby script to create categories from the console, which wouldn't require IDs. They noted that categories can be created with just a name, but additional details like description and permissions can be added with more effort.

[Heather_Dudley](/t/-/159867/3) shared a similar experience, where a moderator used a script with an API key to bulk create categories, saving a significant amount of time (over 700 subcategories). They noted that the permissions part of the process was a bit tricky, but overall it was a huge timesaver.

<div class="post-metadata">

**Author:** ![markersocial](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/markersocial/32/170136_2.png) [@markersocial](https://meta.discourse.org/u/markersocial)\
**Post date:** [August 5, 2020, 7:04am UTC](https://meta.discourse.org/t/bulk-category-creation-via-csv/159867/1 "2020-08-05T07:04:24Z")

</div>

I’ve been looking into bulk category creation.

The best I’ve found is this solution: [Administrative Bulk Operations](https://meta.discourse.org/t/administrative-bulk-operations/118349#heading--8)

Though creating those json files for the purpose of bulk creating new custom categories seems quite tedious unless you have some custom builder to create them and assign the ids correctly. Especially if working with any subcategories.

I think it would be a useful feature for Discourse to support bulk category creation via CSV upload, comparable to how tags are uploaded, formatted in a simple way. For example, like below:

| Category | Subcategory 1 | Subcategory 2 | Description |
| --- | --- | --- | --- |
| my custom parent category | | | This category is a parent category |
| my custom parent category | my custom subcategory | | This is a lvl 2 subcategory |
| my custom parent category | my custom subcategory | my custom sub-subcategory | This is a lvl 3 subcategory |

Expanding on this to include other custom options/columns could be considered as well.

Here is an example json entry for a category, when exported using this method: [Administrative Bulk Operations](https://meta.discourse.org/t/administrative-bulk-operations/118349#heading--8)

```
{
  "id": 1,
  "name": "Uncategorized",
  "color": "0088CC",
  "created_at": "2020-07-23T02:27:33.970Z",
  "user_id": -1,
  "slug": "uncategorized",
  "description": "",
  "text_color": "FFFFFF",
  "auto_close_hours": null,
  "position": 0,
  "parent_category_id": null,
  "auto_close_based_on_last_post": false,
  "topic_template": null,
  "all_topics_wiki": false,
  "permissions_params": {}
},

```

---

<div class="post-metadata">

**Author:** ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)\
**Post date:** [August 5, 2020, 12:42pm UTC](https://meta.discourse.org/t/bulk-category-creation-via-csv/159867/2 "2020-08-05T12:42:22Z")

</div>

It’s rare to need to create many categories, so the likelihood that whether interface there is well be to cumbersome to be worthwhile is high.

What I would do is write a ruby script to create the categories from the console. You don’t need any ID. I think you can create them with only the name, but you can also load the description, and permissions if you try hard.

---

<div class="post-metadata">

**Author:** ![Heather\_Dudley](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/heather_dudley/32/151925_2.png) [@Heather\_Dudley](https://meta.discourse.org/u/Heather_Dudley)\
**Post date:** [August 5, 2020, 10:53pm UTC](https://meta.discourse.org/t/bulk-category-creation-via-csv/159867/3 "2020-08-05T22:53:33Z")

</div>

When we did this, one of our mods ran a script with an API key to bulk create these en masse. It worked really well, although if I recall the permissions part was a little weird. Otherwise, it was a HUGE timesaver (we had over 700 subcategories to create).
