Procedural generation in 2D platformers

im currently making a 2D platformer and i want to procedurally generate the map how would i go about this

That Question is so broad that the only valid answer would be:

“use some sort of noise function”


the most likely approach working for you is to prepare modular pieces of elements which would work on their own and puzzle them together randomly - you could extend this by having each module append a list about which other modules can attach to it etc

You can check how Dead Cells created their map, there are quite many videos about that in Youtube and many articles, basically they have a set of rooms and some random function to put those rooms around. Creating the whole level like you mention is quite hard to get something that will always work.

This is a Roguelike rooms and maze generator, but could be adapted to what you are trying to do.

Could be worth a look.