Methods and apparatus for shaping pipes, tubes, liners, or casing at downhole locations in wells. Use is made of rollers bearing radially outwards against the inside wall of the pipe (etc.), the rollers being rolled around the pipe to cause outward plastic deformation which expands and shapes the pipe to a desired profile. Where one pipe is inside another, the two pipes can be joined without separate components (except optional seals). Landing nipples and liner hangers can be formed in situ. Valves can be deployed to a selected downhole location and there sealed to the casing or liner without separate packers. Casing can be deployed downhole in reduced-diameter lengths and then expanded to case a well without requiring larger diameter bores and causing further uphole. The invention enables simplified downhole working, and enables a well to be drilled & produced with the minimum downhole bore throughout its depth, obviating the need for large bores. When expanding lengths of casing, the casing does not need to be anchored to made pressure-tight. The profiling/expansion tools of the invention can be deployed downhole on coiled tubing, and operated without high tensile loads on the coiled tubing.