Prepare the cream cheese filling: In a medium bowl, add the softened cream cheese, sugar, vanilla extract, and egg yolk if using. Mix everything together until the mixture becomes smooth, creamy, and slightly fluffy. Make sure there are no lumps so the filling spreads evenly and bakes into a soft, rich center.
Prepare the puff pastry: Lightly flour your surface and unfold the puff pastry sheet. If it feels too stiff, let it sit for a few minutes at room temperature so it becomes easier to handle. Cut the pastry into 6–8 equal rectangles or squares, depending on your preferred size. Arrange them on a baking tray lined with parchment paper, leaving space between each piece.
Shape the Danish pastries: Using a knife, gently score a smaller rectangle inside each pastry piece, leaving a border around the edges. Be careful not to cut all the way through. This helps the edges puff up while keeping the center slightly sunken for the filling. Prick the center lightly with a fork to prevent excessive puffing.
Add the filling: Spoon about 1 tablespoon of cream cheese mixture into the center of each pastry and spread it evenly within the inner square. Add a teaspoon of raspberry jam on top of the cream cheese layer, then gently swirl them together using a toothpick or spoon for a marbled effect. If using fresh raspberries, place a few on top for extra texture and fruit bursts.
Apply egg wash and bake: In a small bowl, whisk the egg with milk to create an egg wash. Brush the edges of each pastry lightly to help them turn golden and shiny during baking. Preheat your oven to 375°F (190°C) and bake for 18–25 minutes, or until the pastry is puffed, golden brown, and crisp around the edges while the filling is set.
Finish and serve: Remove the danishes from the oven and let them cool for at least 10 minutes so the filling can set properly. Dust lightly with powdered sugar before serving for a bakery-style finish. Serve warm or at room temperature for the best creamy texture and fruity flavor.