How to leave a postdoc prematurely without burning bridges? I am in the middle of a postdoc that I want to quit to move to another postdoc. I don’t have experience with changing jobs in academia so I am looking for an advice how to accomplish this in the least painful way.

There are many threads on SE about quitting a job, mostly on the workplace. In industry it’s simple: upon finding a new job, one gives notice without prior announcement and completes the notice period. And in most cases it’s understandable and it doesn’t burn bridges.

Academia might be different: relations are more sensitive, and circles are smaller as one needs recommendation letters, get papers and grants reviewed, and so on.

So the question is how to leave a postdoc prematurely without burning bridges?

Is it better to just quit without much explanation or to gradually announce to my professor that I would like to start looking for a new postdoc because I am not happy with the current one?

The main reason for quitting is that I don’t find the department to be a nice environment and I am doing menial work from which I don’t benefit. Explaining these reasons won’t be received well by the professor and the department because they think that the project is great. People are nice to me but discussing this won’t help nor much can change my mind. On the other hand, I’m not sure if suddenly quitting will be received well too and might jeopardize my future career.
Speaking as someone who has seen how disruptive unexpected departures can be to a project, earlier notice is almost always better for your advisor, and I think you are less likely to burn bridges if you 1) let them know as soon as possible, and 2) try to finish things up / leave them in a state where someone else can take over.  All this is probably similar to industry, except that the lead time is probably much longer (since it takes longer to be hired, usually).

The caveat here is that you have to make a call about your advisor's temper. If you think your advisor is a bitter or petty person who will dislike you for leaving under any circumstances, waiting until later might be your only option, because you will burn bridges either way, and you do not want to be abused for several months. This is a rare circumstance, and it doesn't sound like your case. 

Here's the other big point: unless you think there is something you can do to improve the environment which would make you stay (doesn't sound like there is), being too detailed about why you are leaving is only going to make people angrier. Saying "I don’t find the department to be a nice environment and I am doing menial work from which I don’t benefit" - whether or not it is true that your tasks are menial - will aggravate people, as you guessed. Saying, "I haven't found this line of research as exciting as I hoped" is probably enough, and (if you know) saying "I want to move more in the direction X" might be good.