Skip to content

HowTo: Increasing the number of characters in posts in Mastodon 4.2.0

The Mastodon Logo
Das Mastodon Logo
The default character limit for new toots in Mastodon is 500. But what if you want to increase or decrease it? With Mastodon version 4.2.*, the previous instructions for adjusting or increasing the number of characters in posts are obsolete. Basically, the compose.js file is now called differently and must be edited in a different path. I show how, with a big thank you to drakfrid, whose instructions I have adapted accordingly:

We will edit three different files, two which set the character limit on your instance, and one which tells other clients or apps what your custom character limit is (for those that support it).

1. Switch to the mastodon user
su - mastodon

2. Edit the file live/app/javascript/mastodon/features/compose/component/compose_form.js in your favourite text editor,
nano live/app/javascript/mastodon/features/compose/components/compose_form.js

find the number 500 (it should be written in two different locations). Change both of them to whatever you like.

3. Edit live/app/validators/statuslengthvalidator.rb,
nano live/app/validators/status_length_validator.rb

and once again find the number 500 (should exist only once) and change it to the same number as you wrote in the previous file.

4. Edit live/app/serializers/rest/instance_serializer.rb,
nano live/app/serializers/rest/instance_serializer.rb

and find the row starting with
:languages, :registrations,
(should be the ~8th row), and change it so it includes ”:maxtootchars” after ”:registrations”, such as
:languages, :registrations, :maxtootchars,
where the full row now looks something like
:languages, :registrations, :maxtootchars, :approvalrequired, :invitesenabled

At the end of the same file, above where it says private, add the following code:
def max_toot_chars
   <your value here>
end

and change <your value here> to the same value you wrote previously.

5. Enter the live directory and recompile Mastodon,
RAILS_ENV=production bundle exec rails assets:precompile

6. Switch to the root user (with exit), and restart the Mastodon services,
systemctl restart mastodon-sidekiq
systemctl reload mastodon-web

and optionally restart the streaming API server,
systemctl restart mastodon-streaming

And you’re done! You should now be able to see the new character limit on your Mastodon instance.
cronjob